We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e817930 commit 0c7845bCopy full SHA for 0c7845b
pandas/tests/tslibs/test_array_to_datetime.py
@@ -298,3 +298,20 @@ def test_datetime_subclass(klass):
298
299
expected = np.array(["2000-01-01T00:00:00.000000"], dtype="M8[us]")
300
tm.assert_numpy_array_equal(result, expected)
301
+
302
303
+import pandas as pd
304
+from pandas import Timestamp
305
+import pandas._testing as tm
306
307
308
+def test_to_datetime_format_long_string_gh54958():
309
+ """
310
+ Test that to_datetime with a specific format doesn't fail on strings
311
+ that are longer than the format implies.
312
+ GH#54958
313
314
+ ser = pd.Series(["2023010100"])
315
+ expected = pd.Series([Timestamp("2023-01-01")])
316
+ result = pd.to_datetime(ser, format="%Y%m%d")
317
+ tm.assert_series_equal(result, expected)
0 commit comments