repr for PeriodIndex does not handle <=2 elements well (original) (raw)
The repr
for PeriodIndex
uses ellipses (i.e. ...) for all number of elements. Ellipses should only be used for more than two elements. DatetimeIndex
correctly does this:
In [9]: pd.period_range('2013Q1', periods=1, freq="Q")
Out[9]:
<class 'pandas.tseries.period.PeriodIndex'>
freq: Q-DEC
[2013Q1, ..., 2013Q1]
length: 1
In [11]: pd.period_range('2013Q1', periods=2, freq="Q")
Out[11]:
<class 'pandas.tseries.period.PeriodIndex'>
freq: Q-DEC
[2013Q1, ..., 2013Q2]
length: 2
In [10]: pd.period_range('2013Q1', periods=3, freq="Q")
Out[10]:
<class 'pandas.tseries.period.PeriodIndex'>
freq: Q-DEC
[2013Q1, ..., 2013Q3]
length: 3
compare to:
In [16]: pd.date_range('2013-01-01', periods=3, freq="Q")
Out[16]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2013-03-31 00:00:00, ..., 2013-09-30 00:00:00]
Length: 3, Freq: Q-DEC, Timezone: None
In [13]: pd.date_range('2013-01-01', periods=2, freq="Q")
Out[13]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2013-03-31 00:00:00, 2013-06-30 00:00:00]
Length: 2, Freq: Q-DEC, Timezone: None
In [14]: pd.date_range('2013-01-01', periods=1, freq="Q")
Out[14]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2013-03-31 00:00:00]
Length: 1, Freq: Q-DEC, Timezone: None