File tree 2 files changed +23
-2
lines changed
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -433,11 +433,15 @@ def __abs__(self) -> Self:
433
433
# https://issues.apache.org/jira/browse/ARROW-10739 is addressed
434
434
def __getstate__ (self ):
435
435
state = self .__dict__ .copy ()
436
- state ["_data " ] = self ._pa_array .combine_chunks ()
436
+ state ["_pa_array " ] = self ._pa_array .combine_chunks ()
437
437
return state
438
438
439
439
def __setstate__ (self , state ) -> None :
440
- state ["_pa_array" ] = pa .chunked_array (state ["_data" ])
440
+ if "_data" in state :
441
+ data = state .pop ("_data" )
442
+ else :
443
+ data = state ["_pa_array" ]
444
+ state ["_pa_array" ] = pa .chunked_array (data )
441
445
self .__dict__ .update (state )
442
446
443
447
def _cmp_method (self , other , op ):
Original file line number Diff line number Diff line change @@ -2351,3 +2351,20 @@ def test_concat_empty_arrow_backed_series(dtype):
2351
2351
expected = ser .copy ()
2352
2352
result = pd .concat ([ser [np .array ([], dtype = np .bool_ )]])
2353
2353
tm .assert_series_equal (result , expected )
2354
+
2355
+
2356
+ # _data was renamed to _pa_data
2357
+ class OldArrowExtensionArray (ArrowExtensionArray ):
2358
+ def __getstate__ (self ):
2359
+ state = super ().__getstate__ ()
2360
+ state ["_data" ] = state .pop ("_pa_array" )
2361
+ return state
2362
+
2363
+
2364
+ def test_pickle_old_arrowextensionarray ():
2365
+ data = pa .array ([1 ])
2366
+ expected = OldArrowExtensionArray (data )
2367
+ result = pickle .loads (pickle .dumps (expected ))
2368
+ tm .assert_extension_array_equal (result , expected )
2369
+ assert result ._pa_array == pa .chunked_array (data )
2370
+ assert not hasattr (result , "_data" )
You can’t perform that action at this time.
0 commit comments