@@ -757,12 +757,29 @@ def test_any_all(values, exp_any, exp_all, exp_any_noskip, exp_all_noskip):
757
757
# result = arr[mask]
758
758
759
759
760
- @pytest .mark .skip (reason = "broken test" )
761
760
@td .skip_if_no ("pyarrow" , min_version = "0.15.0" )
762
761
def test_arrow_array (data ):
763
762
# protocol added in 0.15.0
764
763
import pyarrow as pa
765
764
766
765
arr = pa .array (data )
767
- expected = pa .array (np .array (data , dtype = object ), type = pa .bool_ (), from_pandas = True )
766
+
767
+ # TODO use to_numpy(na_value=None) here
768
+ data_object = np .array (data , dtype = object )
769
+ data_object [data .isna ()] = None
770
+ expected = pa .array (data_object , type = pa .bool_ (), from_pandas = True )
768
771
assert arr .equals (expected )
772
+
773
+
774
+ @td .skip_if_no ("pyarrow" , min_version = "0.15.1.dev" )
775
+ def test_arrow_roundtrip ():
776
+ # roundtrip possible from arrow 1.0.0
777
+ import pyarrow as pa
778
+
779
+ data = pd .array ([True , False , None ], dtype = "boolean" )
780
+ df = pd .DataFrame ({"a" : data })
781
+ table = pa .table (df )
782
+ assert table .field ("a" ).type == "bool"
783
+ result = table .to_pandas ()
784
+ assert isinstance (result ["a" ].dtype , pd .BooleanDtype )
785
+ tm .assert_frame_equal (result , df )
0 commit comments