Skip to content

Slow setting PeriodIndex vs DatetimeIndex #13173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bartbkr opened this issue May 13, 2016 · 1 comment
Closed

Slow setting PeriodIndex vs DatetimeIndex #13173

bartbkr opened this issue May 13, 2016 · 1 comment
Labels
Performance Memory or execution speed performance Period Period data type

Comments

@bartbkr
Copy link

bartbkr commented May 13, 2016

When attempting to set an index using a Period rather than a Datetime,
the performance significantly deteriorates. A small example:

import pandas as pa
obs = 1000
start_date = '1/1/1900'
df = pa.DataFrame(list(range(1, obs + 1)))
df['dateindex'] = pa.date_range('1/1/1900', periods=obs, freq='M')
df['periodindex'] = pa.period_range('1/1/1900', periods=obs, freq='M')
%timeit df.set_index('dateindex')
#1000 loops, best of 3: 444 µs per loop
%timeit df.set_index('periodindex')
#1000 loops, best of 3: 1.89 ms per loop

This difference in performance becomes especially frustrating with
larger dataframes. In order for Period to be as useful as Datetime,
these should be much closer in performance.

@jreback
Copy link
Contributor

jreback commented May 13, 2016

this is a symptom of #7964 it is an object dtype now and is not first class. contributions along those lines are welcome.

@jreback jreback closed this as completed May 13, 2016
@jreback jreback added Performance Memory or execution speed performance Period Period data type labels May 13, 2016
@jreback jreback added this to the No action milestone May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance Period Period data type
Projects
None yet
Development

No branches or pull requests

2 participants