Skip to content

BUG: Setting Timestamp with timezone with .at raises TypeError #25506

Closed
@int8

Description

@int8

Code Sample, a copy-pastable example if possible

import pytz 
import pandas 

series = pd.Series(pd.Timestamp('2017-08-05 00:00:00+0100', tz=pytz.FixedOffset(60)))
series.at[1] = pd.Timestamp('2017-08-05 00:00:00+0100', tz=pytz.FixedOffset(60))

# this produces 
TypeError: Argument 'arr' has incorrect type (expected numpy.ndarray, got DatetimeArray)

Problem description

I would expect to be able to operate on a series of timestamps

Expected Output

no error

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-45-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.4
pytest: 4.1.1
pip: 18.1
setuptools: 40.6.3
Cython: None
numpy: 1.16.0
scipy: 1.2.0
pyarrow: None
xarray: 0.11.3
IPython: 7.2.0
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: None
tables: 3.4.4
numexpr: 2.6.9
feather: None
matplotlib: 3.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: 1.2.16
pymysql: None
psycopg2: 2.7.6.1 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: 0.9.0
pandas_datareader: None

Activity

mroeschke

mroeschke commented on Mar 1, 2019

@mroeschke
Member

Note loc still works

In [13]: import pytz
    ...: import pandas
    ...:
    ...: series = pd.Series(pd.Timestamp('2017-08-05 00:00:00+0100', tz=pytz.FixedOffset(60)))
    ...: series.loc[1] = pd.Timestamp('2017-08-05 00:00:00+0100', tz=pytz.FixedOffset(60))

In [14]: series
Out[14]:
0   2017-08-05 00:00:00+01:00
1   2017-08-05 00:00:00+01:00
dtype: datetime64[ns, pytz.FixedOffset(60)]

Guessing since switching to ExtensionArrays under the hood at was overlooked. PRs welcome!

added
IndexingRelated to indexing on series/frames, not to indexes themselves
TimezonesTimezone data dtype
on Mar 1, 2019
changed the title [-]Cannot create a series of pandas.Timestamp objects with fixed offset[/-] [+]BUG: Setting Timestamp with timezone with .at raises TypeError[/+] on Mar 1, 2019
added this to the 0.25.0 milestone on Mar 4, 2019
added a commit that references this issue on Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    IndexingRelated to indexing on series/frames, not to indexes themselvesTimezonesTimezone data dtype

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @jreback@mroeschke@int8

      Issue actions

        BUG: Setting Timestamp with timezone with .at raises TypeError · Issue #25506 · pandas-dev/pandas