Skip to content

BUG: caught typeError in series.at (#25506) #25533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Timezones

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

Numeric
^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ def _set_value(self, label, value, takeable=False):
self._values[label] = value
else:
self.index._engine.set_value(self._values, label, value)
except KeyError:
except (KeyError, TypeError):

# set using a non-recursive method
self.loc[label] = value
Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/indexing/test_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pytest
from pytz import FixedOffset

from pandas import DataFrame, Series, Timedelta, Timestamp, date_range
from pandas.tests.indexing.common import Base
Expand Down Expand Up @@ -185,6 +186,17 @@ def test_at_with_tz(self):
result = df.at[0, 'date']
assert result == expected

@pytest.mark.parametrize('tz', [
None, 'UTC', 'US/Eastern', 'Asia/Tokyo',
'dateutil/US/Pacific', 'CET', FixedOffset(60)])
def test_series_set_tz_timestamp(self, tz):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the tz_naive_fixture (i.e. def test_series_set_tz_timestamp(self, tz_naive_fixture)) instead of specifying all these tzs

Copy link
Contributor Author

@jopenmolles jopenmolles Mar 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, did not know how it worked. Thanks will do that right now!

# GH 25506
ts = Timestamp('2017-08-05 00:00:00+0100', tz=tz)
result = Series(ts)
result.at[1] = ts
expected = Series([ts, ts])
tm.assert_series_equal(result, expected)

def test_mixed_index_at_iat_loc_iloc_series(self):
# GH 19860
s = Series([1, 2, 3, 4, 5], index=['a', 'b', 'c', 1, 2])
Expand Down