@@ -450,10 +450,14 @@ def test_string_column_index(self):
450450
451451 @pytest .mark .parametrize ('unit' , ['us' , 'ns' ])
452452 def test_datetimetz_column_index (self , unit ):
453+ ext_kwargs = {}
454+ if Version (pd .__version__ ) >= Version ("2.0.0" ):
455+ # unit argument not supported on date_range for pandas < 2.0.0
456+ ext_kwargs = {'unit' : unit }
453457 df = pd .DataFrame (
454458 [(1 , 'a' , 2.0 ), (2 , 'b' , 3.0 ), (3 , 'c' , 4.0 )],
455459 columns = pd .date_range (
456- start = '2017-01-01' , periods = 3 , tz = 'America/New_York' , unit = unit
460+ start = '2017-01-01' , periods = 3 , tz = 'America/New_York' , ** ext_kwargs
457461 )
458462 )
459463 t = pa .Table .from_pandas (df , preserve_index = True )
@@ -462,7 +466,10 @@ def test_datetimetz_column_index(self, unit):
462466 column_indexes , = js ['column_indexes' ]
463467 assert column_indexes ['name' ] is None
464468 assert column_indexes ['pandas_type' ] == 'datetimetz'
465- assert column_indexes ['numpy_type' ] == f'datetime64[{ unit } ]'
469+ if ext_kwargs :
470+ assert column_indexes ['numpy_type' ] == f'datetime64[{ unit } ]'
471+ else :
472+ assert column_indexes ['numpy_type' ] == 'datetime64[ns]'
466473
467474 md = column_indexes ['metadata' ]
468475 assert md ['timezone' ] == 'America/New_York'
@@ -711,8 +718,12 @@ def test_mismatch_metadata_schema(self):
711718 # It is possible that the metadata and actual schema is not fully
712719 # matching (eg no timezone information for tz-aware column)
713720 # -> to_pandas() conversion should not fail on that
721+ ext_kwargs = {}
722+ if Version (pd .__version__ ) >= Version ("2.0.0" ):
723+ # unit argument not supported on date_range for pandas < 2.0.0
724+ ext_kwargs = {'unit' : 'ns' }
714725 df = pd .DataFrame ({"datetime" : pd .date_range (
715- "2020-01-01" , periods = 3 , unit = 'ns' )})
726+ "2020-01-01" , periods = 3 , ** ext_kwargs )})
716727
717728 # OPTION 1: casting after conversion
718729 table = pa .Table .from_pandas (df )
0 commit comments