Skip to content

BUG: Incorrect parsing of ISO 8601 durations #36204

Closed
@lmeyerov

Description

@lmeyerov
  • [x ] I have checked that this issue has not already been reported.

  • [ x] 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.


Code Sample, a copy-pastable example

pd.Timedelta('P1Y')
pd.Timedelta('P1M')
pd.Timedelta('P1W')
pd.Timedelta('P1D')
pd.Timedelta('P1DT1H')
pd.Timedelta('PT1H')
pd.Timedelta('P1H')

Problem description

Trying most iso8601 duration formats fails.

For above examples:

  • Expected pd.Timedelta instances of 1yr, 1mo, 1wk, 1d, 1d 1hr
  • ... but got ValueError: Invalid ISO 8601 Duration format - ... on Y/M/W, PT1H
  • ... 1D was '0'
  • ... 1DT1H was '1d' (no hr)

Encountered while trying to figure out neo4j.time.Duration().isoformat() -> pandas ->arrow > rapids cudf timedelta[*] . Neo4j returns values like P1Y3M15DT2H3M and P1Y3M.

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