API: Index doesn't results in PeriodIndex if Period contains NaT #13664

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
1 participant
Member

sinhrks commented Jul 15, 2016

  • tests added / passed
  • passes git diff upstream/master | flake8 --diff
  • whatsnew entry

This improve Period handling a little.

  • normal Index constructor can accept:
    • Period and NaT mixed input (result is PeriodIndex) Period version of #13477)
    • Period with multiple freq (result is object dtype)
  • PeriodIndex.fillna can accept Period with different freq (result is object dtype)

The below describes the behavior on current master

# this should be PeriodIndex
pd.Index([pd.Period('2011-01', freq='M'), pd.NaT])
# Index([2011-01, NaT], dtype='object')

# this should be object dtype
pd.Index([pd.Period('2011-01', freq='M'), pd.Period('2011-01-01', freq='D')])
# pandas._period.IncompatibleFrequency: Input has different freq=D from PeriodIndex(freq=M)

# this should be object dtype
pd.PeriodIndex(['2011-01', 'NaT'], freq='M').fillna(pd.Period('2011-01-01', freq='D'))
# pandas._period.IncompatibleFrequency: Input has different freq=D from PeriodIndex(freq=M)

sinhrks added this to the 0.19.0 milestone Jul 15, 2016

@sinhrks sinhrks API: Index doesn't results in PeriodIndex if Period contains NaT
b208a9e

jreback closed this in 506520b Jul 19, 2016

sinhrks deleted the sinhrks:period_infer2 branch Jul 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment