@@ -1936,24 +1936,24 @@ def test_to_timestamp_unit_coerce(self, bad_val):
1936
1936
tm .assert_index_equal (result , expected )
1937
1937
1938
1938
def test_float_to_datetime_raise_near_bounds (self ):
1939
- msg = "cannot convert input with unit 'Y '"
1940
- oneyear_in_ns = 1e9 * 60 * 60 * 24 * 365.2425
1941
- tsmax_in_years = 2 ** 63 / oneyear_in_ns # 2**63 ns, in years
1939
+ msg = "cannot convert input with unit 'D '"
1940
+ oneday_in_ns = 1e9 * 60 * 60 * 24
1941
+ tsmax_in_days = 2 ** 63 / oneday_in_ns # 2**63 ns, in days
1942
1942
# just in bounds
1943
1943
should_succeed = Series (
1944
- [0 , tsmax_in_years - 0.05 , - tsmax_in_years + 0.05 ], dtype = float
1944
+ [0 , tsmax_in_days - 0.05 , - tsmax_in_days + 0.05 ], dtype = float
1945
1945
)
1946
- expected = (should_succeed * oneyear_in_ns ).astype (np .int64 )
1946
+ expected = (should_succeed * oneday_in_ns ).astype (np .int64 )
1947
1947
for error_mode in ["raise" , "coerce" , "ignore" ]:
1948
- result1 = to_datetime (should_succeed , unit = "Y " , errors = error_mode )
1948
+ result1 = to_datetime (should_succeed , unit = "D " , errors = error_mode )
1949
1949
tm .assert_almost_equal (result1 .astype (np .int64 ), expected , rtol = 1e-10 )
1950
1950
# just out of bounds
1951
- should_fail1 = Series ([0 , tsmax_in_years + 0.05 ], dtype = float )
1952
- should_fail2 = Series ([0 , - tsmax_in_years - 0.05 ], dtype = float )
1951
+ should_fail1 = Series ([0 , tsmax_in_days + 0.05 ], dtype = float )
1952
+ should_fail2 = Series ([0 , - tsmax_in_days - 0.05 ], dtype = float )
1953
1953
with pytest .raises (OutOfBoundsDatetime , match = msg ):
1954
- to_datetime (should_fail1 , unit = "Y " , errors = "raise" )
1954
+ to_datetime (should_fail1 , unit = "D " , errors = "raise" )
1955
1955
with pytest .raises (OutOfBoundsDatetime , match = msg ):
1956
- to_datetime (should_fail2 , unit = "Y " , errors = "raise" )
1956
+ to_datetime (should_fail2 , unit = "D " , errors = "raise" )
1957
1957
1958
1958
1959
1959
class TestToDatetimeDataFrame :
0 commit comments