Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pandas/tests/tslibs/test_array_to_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,19 @@ def test_datetime_subclass(klass):

expected = np.array(["2000-01-01T00:00:00.000000"], dtype="M8[us]")
tm.assert_numpy_array_equal(result, expected)


import pandas as pd
from pandas import Timestamp


def test_to_datetime_format_long_string_gh54958():
"""
Test that to_datetime with a specific format doesn't fail on strings
that are longer than the format implies.
GH#54958
"""
ser = pd.Series(["2023010100"])
expected = pd.Series([Timestamp("2023-01-01")])
result = pd.to_datetime(ser, format="%Y%m%d")
tm.assert_series_equal(result, expected)
Loading