Skip to content

Commit ad7c8ef

Browse files
committed
BUG-23451 Add whatsnew and other requested changes
1 parent 9d03b80 commit ad7c8ef

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

doc/source/whatsnew/v0.24.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@ Datetimelike
11151115
- Bug in :func:`DataFrame.combine` with datetimelike values raising a TypeError (:issue:`23079`)
11161116
- Bug in :func:`date_range` with frequency of ``Day`` or higher where dates sufficiently far in the future could wrap around to the past instead of raising ``OutOfBoundsDatetime`` (:issue:`14187`)
11171117
- Bug in :class:`PeriodIndex` with attribute ``freq.n`` greater than 1 where adding a :class:`DateOffset` object would return incorrect results (:issue:`23215`)
1118+
- Bug in :class:`Series` that interpreted string indices as lists of characters when setting datetimelike values
11181119

11191120
Timedelta
11201121
^^^^^^^^^

pandas/core/series.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -947,10 +947,9 @@ def _set_with(self, key, value):
947947
except Exception:
948948
pass
949949

950-
if isinstance(key, str):
950+
if is_scalar(key):
951951
key = [key]
952-
953-
if not isinstance(key, (list, Series, np.ndarray, Series)):
952+
elif not isinstance(key, (list, Series, np.ndarray)):
954953
try:
955954
key = list(key)
956955
except Exception:

pandas/tests/series/test_datetime_values.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ def test_minmax_nat_dataframe(self, nat):
550550
assert nat.max()[0] is pd.NaT
551551

552552
def test_set_dt_with_string_index(self):
553-
from datetime import date
553+
# GH 23451
554554
x = pd.Series([1, 2, 3], index=['Date', 'b', 'other'])
555-
x.Date = date.today()
555+
x['Date'] = date.today()
556556
assert x.Date == date.today()
557+
assert x['Date'] == date.today()

0 commit comments

Comments
 (0)