Skip to content

Adding offset to Timestamp discards freq information when freq="M" or "W" #27182

Closed
@lostella

Description

@lostella

Code Sample, a copy-pastable example if possible

ts = pd.Timestamp("2019-01-01", freq="M")
ts1 = ts + 1 * ts.freq
print(ts1.freq)

Problem description

There seem to be a problem when a new pd.Timestamp is constructed by adding a multiple of the frequency to an initial timestamp: when the frequency is "M" or "W", then the frequency information is lost in the resulting timestamp.

I'm not sure if this is intended behaviour (for some reason), but it seems to be inconsistent across frequencies.

Expected Output

<MonthEnd>

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

INSTALLED VERSIONS

commit: None

pandas: 0.24.2
pytest: None
pip: 19.1.1
setuptools: 41.0.1
Cython: None
numpy: 1.16.4
scipy: None
pyarrow: None
xarray: None
IPython: 7.6.0
sphinx: None
patsy: None
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions