Description
Code Sample, a copy-pastable example if possible
In [1]: import pandas as pd
In [2]: index = pd.PeriodIndex(start='1952', periods=50000, freq='B')
In [3]: %timeit index.size
10 loops, best of 3: 102 ms per loop
In [4]: %timeit index._values.size
The slowest run took 24.79 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 233 ns per loop
Problem description
@sinhrks - now that the PeriodIndex
call to .values
unboxes all the periods, operations like PeriodIndex.size
are much slower.
What's the best way around this? Should we override more methods so that they call into ._values
rather than .values
?
Output of pd.show_versions()
In [6]: pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 16.1.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.19.1
nose: 1.3.7
pip: 9.0.1
setuptools: 28.8.0
Cython: None
numpy: 1.11.2
scipy: 0.18.1
statsmodels: 0.6.1
xarray: 0.8.2
IPython: 5.1.0
sphinx: None
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.7
blosc: None
bottleneck: 1.2.0
tables: None
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: None
xlrd: None
xlwt: 1.1.2
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: 0.9.2
apiclient: 1.5.5
sqlalchemy: 1.1.4
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.43.0
pandas_datareader: None