@@ -1812,14 +1812,6 @@ def test_strptime():
18121812@pytest .mark .skipif (sys .platform == 'win32' ,
18131813 reason = "Timezone database is not available on Windows yet" )
18141814def test_strftime ():
1815- from pyarrow .vendored .version import Version
1816-
1817- def _fix_timestamp (s ):
1818- if Version (pd .__version__ ) < Version ("1.0.0" ):
1819- return s .to_series ().replace ("NaT" , pd .NaT )
1820- else :
1821- return s
1822-
18231815 times = ["2018-03-10 09:00" , "2038-01-31 12:23" , None ]
18241816 timezones = ["CET" , "UTC" , "Europe/Ljubljana" ]
18251817
@@ -1834,50 +1826,51 @@ def _fix_timestamp(s):
18341826 for fmt in formats :
18351827 options = pc .StrftimeOptions (fmt )
18361828 result = pc .strftime (tsa , options = options )
1837- expected = pa .array (_fix_timestamp ( ts .strftime (fmt ) ))
1829+ expected = pa .array (ts .strftime (fmt ))
18381830 assert result .equals (expected )
18391831
18401832 fmt = "%Y-%m-%dT%H:%M:%S"
18411833
18421834 # Default format
18431835 tsa = pa .array (ts , type = pa .timestamp ("s" , timezone ))
18441836 result = pc .strftime (tsa , options = pc .StrftimeOptions ())
1845- expected = pa .array (_fix_timestamp ( ts .strftime (fmt ) ))
1837+ expected = pa .array (ts .strftime (fmt ))
18461838 assert result .equals (expected )
18471839
18481840 # Default format plus timezone
18491841 tsa = pa .array (ts , type = pa .timestamp ("s" , timezone ))
18501842 result = pc .strftime (tsa , options = pc .StrftimeOptions (fmt + "%Z" ))
1851- expected = pa .array (_fix_timestamp ( ts .strftime (fmt + "%Z" ) ))
1843+ expected = pa .array (ts .strftime (fmt + "%Z" ))
18521844 assert result .equals (expected )
18531845
18541846 # Pandas %S is equivalent to %S in arrow for unit="s"
18551847 tsa = pa .array (ts , type = pa .timestamp ("s" , timezone ))
18561848 options = pc .StrftimeOptions ("%S" )
18571849 result = pc .strftime (tsa , options = options )
1858- expected = pa .array (_fix_timestamp ( ts .strftime ("%S" ) ))
1850+ expected = pa .array (ts .strftime ("%S" ))
18591851 assert result .equals (expected )
18601852
18611853 # Pandas %S.%f is equivalent to %S in arrow for unit="us"
18621854 tsa = pa .array (ts , type = pa .timestamp ("us" , timezone ))
18631855 options = pc .StrftimeOptions ("%S" )
18641856 result = pc .strftime (tsa , options = options )
1865- expected = pa .array (_fix_timestamp ( ts .strftime ("%S.%f" ) ))
1857+ expected = pa .array (ts .strftime ("%S.%f" ))
18661858 assert result .equals (expected )
18671859
18681860 # Test setting locale
18691861 tsa = pa .array (ts , type = pa .timestamp ("s" , timezone ))
18701862 options = pc .StrftimeOptions (fmt , locale = "C" )
18711863 result = pc .strftime (tsa , options = options )
1872- expected = pa .array (_fix_timestamp ( ts .strftime (fmt ) ))
1864+ expected = pa .array (ts .strftime (fmt ))
18731865 assert result .equals (expected )
18741866
18751867 # Test timestamps without timezone
18761868 fmt = "%Y-%m-%dT%H:%M:%S"
18771869 ts = pd .to_datetime (times )
18781870 tsa = pa .array (ts , type = pa .timestamp ("s" ))
18791871 result = pc .strftime (tsa , options = pc .StrftimeOptions (fmt ))
1880- expected = pa .array (_fix_timestamp (ts .strftime (fmt )))
1872+ expected = pa .array (ts .strftime (fmt ))
1873+
18811874 # Positional format
18821875 assert pc .strftime (tsa , fmt ) == result
18831876
@@ -1956,8 +1949,6 @@ def _check_datetime_components(timestamps, timezone=None):
19561949
19571950@pytest .mark .pandas
19581951def test_extract_datetime_components ():
1959- from pyarrow .vendored .version import Version
1960-
19611952 timestamps = ["1970-01-01T00:00:59.123456789" ,
19621953 "2000-02-29T23:23:23.999999999" ,
19631954 "2033-05-18T03:33:20.000000000" ,
@@ -1983,8 +1974,6 @@ def test_extract_datetime_components():
19831974 if sys .platform == 'win32' :
19841975 # TODO: We should test on windows once ARROW-13168 is resolved.
19851976 pytest .skip ('Timezone database is not available on Windows yet' )
1986- elif Version (pd .__version__ ) < Version ('1.0.0' ):
1987- pytest .skip ('Pandas < 1.0 extracts time components incorrectly.' )
19881977 else :
19891978 for timezone in timezones :
19901979 _check_datetime_components (timestamps , timezone )
@@ -1995,8 +1984,6 @@ def test_extract_datetime_components():
19951984@pytest .mark .skipif (sys .platform == 'win32' ,
19961985 reason = "Timezone database is not available on Windows yet" )
19971986def test_assume_timezone ():
1998- from pyarrow .vendored .version import Version
1999-
20001987 ts_type = pa .timestamp ("ns" )
20011988 timestamps = pd .to_datetime (["1970-01-01T00:00:59.123456789" ,
20021989 "2000-02-29T23:23:23.999999999" ,
@@ -2040,31 +2027,29 @@ def test_assume_timezone():
20402027
20412028 timezone = "Europe/Brussels"
20422029
2043- # nonexistent parameter was introduced in Pandas 0.24.0
2044- if Version (pd .__version__ ) >= Version ("0.24.0" ):
2045- options_nonexistent_raise = pc .AssumeTimezoneOptions (timezone )
2046- options_nonexistent_earliest = pc .AssumeTimezoneOptions (
2047- timezone , ambiguous = "raise" , nonexistent = "earliest" )
2048- options_nonexistent_latest = pc .AssumeTimezoneOptions (
2049- timezone , ambiguous = "raise" , nonexistent = "latest" )
2050-
2051- with pytest .raises (ValueError ,
2052- match = "Timestamp doesn't exist in "
2053- f"timezone '{ timezone } '" ):
2054- pc .assume_timezone (nonexistent_array ,
2055- options = options_nonexistent_raise )
2056-
2057- expected = pa .array (nonexistent .tz_localize (
2058- timezone , nonexistent = "shift_forward" ))
2059- result = pc .assume_timezone (
2060- nonexistent_array , options = options_nonexistent_latest )
2061- expected .equals (result )
2062-
2063- expected = pa .array (nonexistent .tz_localize (
2064- timezone , nonexistent = "shift_backward" ))
2065- result = pc .assume_timezone (
2066- nonexistent_array , options = options_nonexistent_earliest )
2067- expected .equals (result )
2030+ options_nonexistent_raise = pc .AssumeTimezoneOptions (timezone )
2031+ options_nonexistent_earliest = pc .AssumeTimezoneOptions (
2032+ timezone , ambiguous = "raise" , nonexistent = "earliest" )
2033+ options_nonexistent_latest = pc .AssumeTimezoneOptions (
2034+ timezone , ambiguous = "raise" , nonexistent = "latest" )
2035+
2036+ with pytest .raises (ValueError ,
2037+ match = "Timestamp doesn't exist in "
2038+ f"timezone '{ timezone } '" ):
2039+ pc .assume_timezone (nonexistent_array ,
2040+ options = options_nonexistent_raise )
2041+
2042+ expected = pa .array (nonexistent .tz_localize (
2043+ timezone , nonexistent = "shift_forward" ))
2044+ result = pc .assume_timezone (
2045+ nonexistent_array , options = options_nonexistent_latest )
2046+ expected .equals (result )
2047+
2048+ expected = pa .array (nonexistent .tz_localize (
2049+ timezone , nonexistent = "shift_backward" ))
2050+ result = pc .assume_timezone (
2051+ nonexistent_array , options = options_nonexistent_earliest )
2052+ expected .equals (result )
20682053
20692054 options_ambiguous_raise = pc .AssumeTimezoneOptions (timezone )
20702055 options_ambiguous_latest = pc .AssumeTimezoneOptions (
@@ -2199,11 +2184,6 @@ def _check_temporal_rounding(ts, values, unit):
21992184 "second" , "minute" , "hour" , "day" ))
22002185@pytest .mark .pandas
22012186def test_round_temporal (unit ):
2202- from pyarrow .vendored .version import Version
2203-
2204- if Version (pd .__version__ ) < Version ('1.0.0' ):
2205- pytest .skip ('Pandas < 1.0 rounds differently.' )
2206-
22072187 values = (1 , 2 , 3 , 4 , 5 , 6 , 7 , 10 , 15 , 24 , 60 , 250 , 500 , 750 )
22082188 timestamps = [
22092189 "1923-07-07 08:52:35.203790336" ,
0 commit comments