Skip to content

Commit 5c772af

Browse files
GH-35845: [CI][Python] Fix usage of assert_frame_equal in test_hdfs.py (#35842)
_add empty comment_ * Closes: #35845 Authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
1 parent 95df6cc commit 5c772af

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

‎python/pyarrow/pandas-shim.pxi‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,6 @@ cdef class _PandasAPIShim(object):
225225
return obj.array
226226
return obj.values
227227

228-
def assert_frame_equal(self, *args, **kwargs):
229-
self._check_import()
230-
return self._pd.util.testing.assert_frame_equal
231-
232228
def get_rangeindex_attribute(self, level, name):
233229
# public start/stop/step attributes added in pandas 0.25.0
234230
self._check_import()

‎python/pyarrow/tests/test_hdfs.py‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import pytest
2727

2828
import pyarrow as pa
29-
from pyarrow.pandas_compat import _pandas_api
3029
from pyarrow.tests import util
3130
from pyarrow.tests.parquet.common import _test_dataframe
3231
from pyarrow.tests.parquet.test_dataset import (
@@ -35,6 +34,12 @@
3534
)
3635
from pyarrow.util import guid
3736

37+
try:
38+
from pandas.testing import assert_frame_equal
39+
except ImportError:
40+
pass
41+
42+
3843
# ----------------------------------------------------------------------
3944
# HDFS tests
4045

@@ -317,10 +322,10 @@ def test_read_multiple_parquet_files(self):
317322
expected = self._write_multiple_hdfs_pq_files(tmpdir)
318323
result = self.hdfs.read_parquet(tmpdir)
319324

320-
_pandas_api.assert_frame_equal(result.to_pandas()
321-
.sort_values(by='index')
322-
.reset_index(drop=True),
323-
expected.to_pandas())
325+
assert_frame_equal(
326+
result.to_pandas().sort_values(by='index').reset_index(drop=True),
327+
expected.to_pandas()
328+
)
324329

325330
@pytest.mark.pandas
326331
@pytest.mark.parquet
@@ -335,10 +340,10 @@ def test_read_multiple_parquet_files_with_uri(self):
335340
path = _get_hdfs_uri(tmpdir)
336341
result = pq.read_table(path)
337342

338-
_pandas_api.assert_frame_equal(result.to_pandas()
339-
.sort_values(by='index')
340-
.reset_index(drop=True),
341-
expected.to_pandas())
343+
assert_frame_equal(
344+
result.to_pandas().sort_values(by='index').reset_index(drop=True),
345+
expected.to_pandas()
346+
)
342347

343348
@pytest.mark.pandas
344349
@pytest.mark.parquet
@@ -361,7 +366,7 @@ def test_read_write_parquet_files_with_uri(self):
361366
path, filesystem=self.hdfs, use_legacy_dataset=True
362367
).to_pandas()
363368

364-
_pandas_api.assert_frame_equal(result, df)
369+
assert_frame_equal(result, df)
365370

366371
@pytest.mark.parquet
367372
@pytest.mark.pandas
@@ -420,8 +425,6 @@ def _get_hdfs_uri(path):
420425
@pytest.mark.parquet
421426
@pytest.mark.fastparquet
422427
def test_fastparquet_read_with_hdfs():
423-
from pandas.testing import assert_frame_equal
424-
425428
check_libhdfs_present()
426429
try:
427430
import snappy # noqa

0 commit comments

Comments
 (0)