Skip to content

Commit b3bfed5

Browse files
committed
alterations4
1 parent be1a212 commit b3bfed5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pandas/core/tools/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ def to_datetime(
11501150
if isinstance(format, (list, tuple)):
11511151
format = np.array(format, dtype="O")
11521152
# return list
1153-
return_list = [convert_listlike(arg[i],str(fmt)) for i,fmt in enumerate(format)]
1153+
return_list = [Timestamp(convert_listlike([argc[i]],fmt)[0]) for i,fmt in enumerate(format)]
11541154
# transformed object in DatetimeIndex
11551155
result = DatetimeIndex(return_list)
11561156
else:

pandas/tests/tools/test_to_datetime.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ def test_to_datetime_today_now_unicode_bytes(self, arg):
10861086
def test_to_datetime_now_with_format(self, format, expected_ds, string, attribute):
10871087
# https://github.com/pandas-dev/pandas/issues/50359
10881088
result = to_datetime(["2020-01-03 00:00:00Z", string], format=format, utc=True)
1089-
expected = DatetimeIndex(d
1089+
expected = DatetimeIndex(
10901090
[expected_ds, getattr(Timestamp, attribute)()], dtype="datetime64[ns, UTC]"
10911091
)
10921092
assert (expected - result).max().total_seconds() < 1
@@ -1095,13 +1095,13 @@ def test_to_datetime_now_with_format(self, format, expected_ds, string, attribut
10951095
def test_to_datetime_where_formart_is_list(self):
10961096
# https://github.com/pandas-dev/pandas/issues/55226
10971097
data = ['2023-10-12','2023-10-13 14:30:00']
1098-
all_formats = ['%Y-m-%d','%Y-%m-%d %H:%M:%S']
1098+
all_formats = ['%Y-%m-%d','%Y-%m-%d %H:%M:%S']
10991099
result = to_datetime(data,format=all_formats)
1100-
expect = DatetimeIndex(
1101-
[to_datetime(data[0],all_formats[0]),to_datetime(data[1],all_formats[1])], dtype="datetime64[ns]"
1100+
expected = DatetimeIndex(
1101+
['2023-10-12 00:00:00','2023-10-13 14:30:00'], dtype="datetime64[ns]",
1102+
freq=None
11021103
)
1103-
1104-
tm.assert_index_equal(result,expect)
1104+
tm.assert_index_equal(result,expected)
11051105

11061106

11071107
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)