Skip to content

BUG: the pd.to_timedelta() incorrectly parses the 'M' as minutes. #34968

Closed
@IcToxi

Description

@IcToxi
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

>> pd.Timestamp.today() + pd.to_timedelta('1 M')

Problem description

The documentation in version 1.0.5 is described as follows:

Possible values: (‘Y’, ‘M’, ‘W’, ‘D’, ‘days’, ‘day’, ‘hours’, hour’, ‘hr’, ‘h’,...

Since in such a particular order, it should be understood as year, month, and week.

But running my code gives the result of a minute for 'M'. However, 'Y' produces the correct parsing result.

I've seen some discussion there about parameters optimization, and whatever the outcome of the discussion, you shouldn't continue to place this bug here, please either change the function or change the documentation.

And perhaps you might consider separating to_datedelta api to reduce complexity.

Thanks.

Expected Output

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.6.final.0
python-bits : 64
OS : Linux
OS-release : 3.10.0-1127.10.1.el7.x86_64
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.0.5
numpy : 1.18.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions