File tree 2 files changed +23
-9
lines changed
2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -540,9 +540,12 @@ def test_unsupported(self):
540
540
# https://github.com/wesm/feather/issues/240
541
541
# serializing actual python objects
542
542
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 )
546
549
547
550
# non-strings
548
551
df = pd .DataFrame ({'a' : ['a' , 1 , 2.0 ]})
Original file line number Diff line number Diff line change @@ -2580,15 +2580,26 @@ def _pytime_to_micros(pytime):
2580
2580
def test_convert_unsupported_type_error_message ():
2581
2581
# ARROW-1454
2582
2582
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 ()]})
2587
2588
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 ):
2590
2591
pa .Table .from_pandas (df )
2591
2592
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
+
2592
2603
2593
2604
# ----------------------------------------------------------------------
2594
2605
# Test object deduplication in to_pandas
You can’t perform that action at this time.
0 commit comments