Skip to content

BUG/API PeriodIndex handles int list/array differently  #14048

Closed
@sinhrks

Description

@sinhrks

When we pass a list of numbers, it parsed as date as it is. The same values is regarded as ordinal if it is passed as an array.

Code Sample, a copy-pastable example if possible

raw = [2005, 2007, 2009]

pd.PeriodIndex(raw, freq='A')
# PeriodIndex(['2005', '2007', '2009'], dtype='period[A-DEC]', freq='A-DEC')

pd.PeriodIndex(np.array(raw), freq='A')
# PeriodIndex(['3975', '3977', '3979'], dtype='period[A-DEC]', freq='A-DEC')

Expected Output

Because PeriodIndex has a data and ordinal arg, it should be regarded as:

  • date if it is passed via data kwd
  • ordinal if it is passed via ordinal kwd

output of pd.show_versions()

on current master.

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