17
17
PY38 ,
18
18
is_platform_windows ,
19
19
)
20
+ from pandas .compat .pyarrow import (
21
+ pa_version_under1p0 ,
22
+ pa_version_under2p0 ,
23
+ )
20
24
import pandas .util ._test_decorators as td
21
25
22
26
import pandas as pd
@@ -653,8 +657,6 @@ def test_categorical(self, pa):
653
657
)
654
658
def test_s3_roundtrip_explicit_fs (self , df_compat , s3_resource , pa , s3so ):
655
659
s3fs = pytest .importorskip ("s3fs" )
656
- if Version (pyarrow .__version__ ) <= Version ("0.17.0" ):
657
- pytest .skip ()
658
660
s3 = s3fs .S3FileSystem (** s3so )
659
661
kw = {"filesystem" : s3 }
660
662
check_round_trip (
@@ -666,8 +668,6 @@ def test_s3_roundtrip_explicit_fs(self, df_compat, s3_resource, pa, s3so):
666
668
)
667
669
668
670
def test_s3_roundtrip (self , df_compat , s3_resource , pa , s3so ):
669
- if Version (pyarrow .__version__ ) <= Version ("0.17.0" ):
670
- pytest .skip ()
671
671
# GH #19134
672
672
s3so = {"storage_options" : s3so }
673
673
check_round_trip (
@@ -698,14 +698,12 @@ def test_s3_roundtrip_for_dir(
698
698
# These are added to back of dataframe on read. In new API category dtype is
699
699
# only used if partition field is string, but this changed again to use
700
700
# category dtype for all types (not only strings) in pyarrow 2.0.0
701
- pa10 = (Version (pyarrow .__version__ ) >= Version ("1.0.0" )) and (
702
- Version (pyarrow .__version__ ) < Version ("2.0.0" )
703
- )
704
701
if partition_col :
705
- if pa10 :
706
- partition_col_type = "int32"
707
- else :
708
- partition_col_type = "category"
702
+ partition_col_type = (
703
+ "int32"
704
+ if (not pa_version_under1p0 ) and pa_version_under2p0
705
+ else "category"
706
+ )
709
707
710
708
expected_df [partition_col ] = expected_df [partition_col ].astype (
711
709
partition_col_type
@@ -795,7 +793,7 @@ def test_write_with_schema(self, pa):
795
793
out_df = df .astype (bool )
796
794
check_round_trip (df , pa , write_kwargs = {"schema" : schema }, expected = out_df )
797
795
798
- @td .skip_if_no ("pyarrow" , min_version = "0.15.0" )
796
+ @td .skip_if_no ("pyarrow" )
799
797
def test_additional_extension_arrays (self , pa ):
800
798
# test additional ExtensionArrays that are supported through the
801
799
# __arrow_array__ protocol
@@ -806,22 +804,10 @@ def test_additional_extension_arrays(self, pa):
806
804
"c" : pd .Series (["a" , None , "c" ], dtype = "string" ),
807
805
}
808
806
)
809
- if Version (pyarrow .__version__ ) >= Version ("0.16.0" ):
810
- expected = df
811
- else :
812
- # de-serialized as plain int / object
813
- expected = df .assign (
814
- a = df .a .astype ("int64" ), b = df .b .astype ("int64" ), c = df .c .astype ("object" )
815
- )
816
- check_round_trip (df , pa , expected = expected )
807
+ check_round_trip (df , pa )
817
808
818
809
df = pd .DataFrame ({"a" : pd .Series ([1 , 2 , 3 , None ], dtype = "Int64" )})
819
- if Version (pyarrow .__version__ ) >= Version ("0.16.0" ):
820
- expected = df
821
- else :
822
- # if missing values in integer, currently de-serialized as float
823
- expected = df .assign (a = df .a .astype ("float64" ))
824
- check_round_trip (df , pa , expected = expected )
810
+ check_round_trip (df , pa )
825
811
826
812
@td .skip_if_no ("pyarrow" , min_version = "1.0.0" )
827
813
def test_pyarrow_backed_string_array (self , pa ):
@@ -831,7 +817,7 @@ def test_pyarrow_backed_string_array(self, pa):
831
817
df = pd .DataFrame ({"a" : pd .Series (["a" , None , "c" ], dtype = "arrow_string" )})
832
818
check_round_trip (df , pa , expected = df )
833
819
834
- @td .skip_if_no ("pyarrow" , min_version = "0.16.0" )
820
+ @td .skip_if_no ("pyarrow" )
835
821
def test_additional_extension_types (self , pa ):
836
822
# test additional ExtensionArrays that are supported through the
837
823
# __arrow_array__ protocol + by defining a custom ExtensionType
@@ -844,7 +830,7 @@ def test_additional_extension_types(self, pa):
844
830
)
845
831
check_round_trip (df , pa )
846
832
847
- @td .skip_if_no ("pyarrow" , min_version = "0.16.0" )
833
+ @td .skip_if_no ("pyarrow" )
848
834
def test_use_nullable_dtypes (self , pa ):
849
835
import pyarrow .parquet as pq
850
836
@@ -880,7 +866,7 @@ def test_timestamp_nanoseconds(self, pa):
880
866
check_round_trip (df , pa , write_kwargs = {"version" : "2.0" })
881
867
882
868
def test_timezone_aware_index (self , pa , timezone_aware_date_list ):
883
- if Version ( pyarrow . __version__ ) >= Version ( "2.0.0" ) :
869
+ if not pa_version_under2p0 :
884
870
# temporary skip this test until it is properly resolved
885
871
# https://github.com/pandas-dev/pandas/issues/37286
886
872
pytest .skip ()
0 commit comments