Skip to content

Commit 76a77a9

Browse files
committed
BUG: Fix Dataframe handling of scalar Timestamp pandas-dev#61444
1 parent 9c5b9ee commit 76a77a9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/core/frame.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
)
4949
from pandas._libs.hashtable import duplicated
5050
from pandas._libs.lib import is_range_indexer
51+
from pandas._libs.tslibs.timestamps import Timestamp
5152
from pandas.compat import PYPY
5253
from pandas.compat._constants import REF_COUNT
5354
from pandas.compat._optional import import_optional_dependency
@@ -4180,6 +4181,14 @@ def __setitem__(self, key, value) -> None:
41804181
):
41814182
# Column to set is duplicated
41824183
self._setitem_array([key], value)
4184+
elif (
4185+
# GH#61444
4186+
isinstance(key, Hashable)
4187+
and key in self.columns
4188+
and is_scalar(value)
4189+
and isinstance(value, (Timestamp, np.datetime64))
4190+
):
4191+
self._set_item(key, [value] * len(self))
41834192
else:
41844193
# set column
41854194
self._set_item(key, value)

0 commit comments

Comments
 (0)