Skip to content

Discrepancy in DateOffset & Timedelta string representation #33094

Open
@yohplala

Description

@yohplala

Code Sample, a copy-pastable example if possible

# DateOffset creation and string representation
off = pd.tseries.frequencies.to_offset('2MS')
off.freqstr
>>> Out[20]: '2MS'

# Timedelta creation from DateOffset string representation
td = pd.to_timedelta(off.freqstr)
td
>>> Out[21] Timedelta('0 days 00:00:00.002000')

# Same for month end 'M'

Problem description

Hello
I am aware Timedelta & DateOffset objects are not supposed to have same representation, but could their string aliases be different when they cannot be mapped to each other?

For Timedelta / minute vs DateOffset / month start ('M'):

  • I understand that representations should be 'min' or 'T' so I am surprised 'M' is accepted by to_timedelta(). To be removed?

For DateOffset / month start vs Timedelta / millisecond ('MS'):

  • maybe month start can be replaced by MB 'Month Begin' ?

Would this make sense?
Bests,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions