Skip to content

Commit 221be3b

Browse files
jopenmollesjreback
authored andcommitted
BUG: caught typeError in series.at (pandas-dev#25506) (pandas-dev#25533)
1 parent a54852a commit 221be3b

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

doc/source/whatsnew/v0.25.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Timezones
150150

151151
- Bug in :func:`to_datetime` with ``utc=True`` and datetime strings that would apply previously parsed UTC offsets to subsequent arguments (:issue:`24992`)
152152
- Bug in :func:`Timestamp.tz_localize` and :func:`Timestamp.tz_convert` does not propagate ``freq`` (:issue:`25241`)
153-
-
153+
- Bug in :func:`Series.at` where setting :class:`Timestamp` with timezone raises ``TypeError`` (:issue:`25506`)
154154

155155
Numeric
156156
^^^^^^^

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ def _set_value(self, label, value, takeable=False):
12291229
self._values[label] = value
12301230
else:
12311231
self.index._engine.set_value(self._values, label, value)
1232-
except KeyError:
1232+
except (KeyError, TypeError):
12331233

12341234
# set using a non-recursive method
12351235
self.loc[label] = value

pandas/tests/indexing/test_scalar.py

+8
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ def test_at_with_tz(self):
185185
result = df.at[0, 'date']
186186
assert result == expected
187187

188+
def test_series_set_tz_timestamp(self, tz_naive_fixture):
189+
# GH 25506
190+
ts = Timestamp('2017-08-05 00:00:00+0100', tz=tz_naive_fixture)
191+
result = Series(ts)
192+
result.at[1] = ts
193+
expected = Series([ts, ts])
194+
tm.assert_series_equal(result, expected)
195+
188196
def test_mixed_index_at_iat_loc_iloc_series(self):
189197
# GH 19860
190198
s = Series([1, 2, 3, 4, 5], index=['a', 'b', 'c', 1, 2])

0 commit comments

Comments
 (0)