Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions python/pyarrow/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import pyarrow as pa
import pyarrow.tests.strategies as past
import pyarrow.compute as pc
from pyarrow.vendored.version import Version


@pytest.mark.processes
Expand Down Expand Up @@ -2737,6 +2738,8 @@ def test_array_from_list_of_timestamps(unit):

@pytest.mark.numpy
def test_array_from_timestamp_with_generic_unit():
if Version(np.__version__) >= Version("2.5.0"):
pytest.skip("generic units of timedelta64 deprecated")
n = np.datetime64('NaT')
x = np.datetime64('2017-01-01 01:01:01.111111111')
y = np.datetime64('2018-11-22 12:24:48.111111111')
Expand Down Expand Up @@ -2778,11 +2781,13 @@ def test_array_from_numpy_timedelta(dtype, type):
@pytest.mark.numpy
def test_array_from_numpy_timedelta_incorrect_unit():
# generic (no unit)
td = np.timedelta64(1)
if Version(np.__version__) < Version("2.5.0"):
# Generic units of timedelta64 deprecated in NumPy 2.5
td = np.timedelta64(1)

for data in [[td], np.array([td])]:
with pytest.raises(NotImplementedError):
pa.array(data)
for data in [[td], np.array([td])]:
with pytest.raises(NotImplementedError):
pa.array(data)

# unsupported unit
td = np.timedelta64(1, 'M')
Expand Down
6 changes: 3 additions & 3 deletions python/pyarrow/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2656,8 +2656,8 @@ def _check_datetime_components(timestamps, timezone=None):
year = ts.dt.year.astype("int64")
month = ts.dt.month.astype("int64")
day = ts.dt.day.astype("int64")
dayofweek = ts.dt.dayofweek.astype("int64")
dayofyear = ts.dt.dayofyear.astype("int64")
dayofweek = ts.dt.day_of_week.astype("int64")
dayofyear = ts.dt.day_of_year.astype("int64")
quarter = ts.dt.quarter.astype("int64")
hour = ts.dt.hour.astype("int64")
minute = ts.dt.minute.astype("int64")
Expand Down Expand Up @@ -2980,7 +2980,7 @@ def test_round_temporal(unit):
if sys.platform == "win32":
timestamps = timestamps[:3] + timestamps[5:]

ts = pd.Series([pd.Timestamp(x, unit="ns") for x in timestamps])
ts = pd.Series([pd.Timestamp(x).as_unit("ns") for x in timestamps])
_check_temporal_rounding(ts, values, unit)

timezones = ["Asia/Kolkata", "America/New_York", "Etc/GMT-4", "Etc/GMT+4",
Expand Down
2 changes: 1 addition & 1 deletion python/pyarrow/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def multisourcefs(request):

# create one with schema partitioning by weekday and color
mockfs.create_dir('schema')
for part, chunk in df_b.groupby([df_b.date.dt.dayofweek, df_b.color]):
for part, chunk in df_b.groupby([df_b.date.dt.day_of_week, df_b.color]):
folder = f'schema/{part[0]}/{part[1]}'
path = f'{folder}/chunk.parquet'
mockfs.create_dir(folder)
Expand Down
11 changes: 6 additions & 5 deletions python/pyarrow/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def _alltypes_example(size=100):

def _check_pandas_roundtrip(df, expected=None, use_threads=False,
expected_schema=None,
check_dtype=True, schema=None,
preserve_index=False,
check_dtype=True, check_freq=True,
schema=None, preserve_index=False,
as_batch=False):
klass = pa.RecordBatch if as_batch else pa.Table
table = klass.from_pandas(df, schema=schema,
Expand All @@ -125,7 +125,8 @@ def _check_pandas_roundtrip(df, expected=None, use_threads=False,
"ignore", "elementwise comparison failed", DeprecationWarning)
tm.assert_frame_equal(result, expected, check_dtype=check_dtype,
check_index_type=('equiv' if preserve_index
else False))
else False),
check_freq=check_freq)


def _check_series_roundtrip(s, type_=None, expected_pa_type=None):
Expand Down Expand Up @@ -223,7 +224,7 @@ def test_column_index_names_datetime(self, tz):
np.random.randn(5, 3),
columns=pd.date_range("2021-01-01", periods=3, freq="50D", tz=tz)
)
_check_pandas_roundtrip(df, preserve_index=True)
_check_pandas_roundtrip(df, preserve_index=True, check_freq=False)

def test_column_index_names_with_decimal(self):
# GH-41503: Test valid roundtrip with decimal value in column index
Expand Down Expand Up @@ -5016,7 +5017,7 @@ def test_does_not_mutate_timedelta_dtype():

assert np.dtype(np.timedelta64) == expected

df = pd.DataFrame({"a": [np.timedelta64()]})
df = pd.DataFrame({"a": [np.timedelta64(0, "s")]})
Comment thread
AlenkaF marked this conversation as resolved.
t = pa.Table.from_pandas(df)
t.to_pandas()

Expand Down
Loading