Skip to content

PERF: much faster to_datetime performance with a format of '%Y%m%d' #4826

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

Merged
merged 1 commit into from
Sep 12, 2013

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Sep 12, 2013

In [1]: rng = date_range('1/1/2000', periods=10000, freq='D')

In [2]: strings = Series(rng.year*10000+rng.month*100+rng.day,dtype=np.int64).apply(str)

In [3]: %timeit pandas.tslib.array_strptime(strings.values,"%Y%m%d")
10 loops, best of 3: 42.9 ms per loop

In [4]: %timeit pd.to_datetime(strings,format="%Y%m%d")
100 loops, best of 3: 9.21 ms per loop

In [5]: (pd.to_datetime(strings,format="%Y%m%d") == pandas.tslib.array_strptime(strings.values,"%Y%m%d")).all()
Out[5]: True

jreback added a commit that referenced this pull request Sep 12, 2013
PERF: much faster to_datetime performance with a format of '%Y%m%d'
@jreback jreback merged commit 41dbca6 into pandas-dev:master Sep 12, 2013
@ghost
Copy link

ghost commented Jan 18, 2014

Does this apply to read_csv as well? I don't think it calls into to_datetime, does it?
we should get our fast paths consistent everywhere

@jreback
Copy link
Contributor Author

jreback commented Jan 18, 2014

I don't believe so, this should be wrapped up in tslib.array_to_datetime / tslib.try_parse_dates

or prob better is to have read_csv use to_datetime (or a related call) directly; the conversions are done after parsing anyhow (so all python and not cython code)

so maybe fix to_datetime (in #5490) and then have another issue to wrap back into read_csv...

@ghost
Copy link

ghost commented Jan 18, 2014

Sounds good, open an issue for 0.14?

Added note: 433ddc3
... and fixed the typos: 38e3b90. sigh

@jreback
Copy link
Contributor Author

jreback commented Jan 18, 2014

yep

This was referenced Jan 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant