Skip to content

Commit a64da2c

Browse files
ARROW-7527: [Python] Fix pandas/feather tests for unsupported types with pandas master
1 parent 7bd4e73 commit a64da2c

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

python/pyarrow/tests/test_feather.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,12 @@ def test_unsupported(self):
540540
# https://github.com/wesm/feather/issues/240
541541
# serializing actual python objects
542542

543-
# period
544-
df = pd.DataFrame({'a': pd.period_range('2013', freq='M', periods=3)})
545-
self._assert_error_on_write(df, TypeError)
543+
# custom python objects
544+
class A:
545+
pass
546+
547+
df = pd.DataFrame({'a': [A(), A()]})
548+
self._assert_error_on_write(df, ValueError)
546549

547550
# non-strings
548551
df = pd.DataFrame({'a': ['a', 1, 2.0]})

python/pyarrow/tests/test_pandas.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -2580,15 +2580,26 @@ def _pytime_to_micros(pytime):
25802580
def test_convert_unsupported_type_error_message():
25812581
# ARROW-1454
25822582

2583-
# period as yet unsupported
2584-
df = pd.DataFrame({
2585-
'a': pd.period_range('2000-01-01', periods=20),
2586-
})
2583+
# custom python objects
2584+
class A:
2585+
pass
2586+
2587+
df = pd.DataFrame({'a': [A(), A()]})
25872588

2588-
expected_msg = 'Conversion failed for column a with type period'
2589-
with pytest.raises(TypeError, match=expected_msg):
2589+
expected_msg = 'Conversion failed for column a with type object'
2590+
with pytest.raises(ValueError, match=expected_msg):
25902591
pa.Table.from_pandas(df)
25912592

2593+
# period unsupported for pandas <= 0.25
2594+
if LooseVersion(pd.__version__) <= '0.25':
2595+
df = pd.DataFrame({
2596+
'a': pd.period_range('2000-01-01', periods=20),
2597+
})
2598+
2599+
expected_msg = 'Conversion failed for column a with type period'
2600+
with pytest.raises(TypeError, match=expected_msg):
2601+
pa.Table.from_pandas(df)
2602+
25922603

25932604
# ----------------------------------------------------------------------
25942605
# Test object deduplication in to_pandas

0 commit comments

Comments
 (0)