File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -2215,6 +2215,10 @@ def objects_to_datetime64ns(
2215
2215
return values .view ("i8" ), tz_parsed
2216
2216
except (ValueError , TypeError ):
2217
2217
raise err
2218
+ except OverflowError as err :
2219
+ # Exception is raised when year is greater than 32 bit signed integer
2220
+ # TODO: Remove this when its fixed in Python
2221
+ raise ValueError ("year out of range" ) from err
2218
2222
2219
2223
if tz_parsed is not None :
2220
2224
# We can take a shortcut since the datetime64 numpy array
Original file line number Diff line number Diff line change @@ -393,6 +393,21 @@ def test_array_not_registered(registry_without_decimal):
393
393
tm .assert_equal (result , expected )
394
394
395
395
396
+ def test_datetime64_eq_string (self ):
397
+ # Issue https://github.com/pandas-dev/pandas/issues/45506
398
+ # Catch OverflowError when comparing datetime64 and string
399
+ data = [
400
+ {"f_0" : "2015-07-01" , "f_2" : "08335394550" },
401
+ {"f_0" : "2015-07-02" , "f_2" : "+49 (0) 0345 300033" },
402
+ {"f_0" : "2015-07-03" , "f_2" : "+49(0)2598 04457" },
403
+ {"f_0" : "2015-07-04" , "f_2" : "0741470003" },
404
+ {"f_0" : "2015-07-05" , "f_2" : "04181 83668" },
405
+ ]
406
+ dtypes = dict (f_0 = 'datetime64[ns]' , f_2 = 'string' )
407
+ df = pd .DataFrame (data = data ).astype (dtypes )
408
+ assert df ['f_0' ].eq (df ['f_2' ]).any () == False
409
+
410
+
396
411
class TestArrayAnalytics :
397
412
def test_searchsorted (self , string_dtype ):
398
413
arr = pd .array (["a" , "b" , "c" ], dtype = string_dtype )
You can’t perform that action at this time.
0 commit comments