Last active
August 29, 2017 18:30
-
-
Save sileht/5ce2163fa23b4376f094edb4dee47332 to your computer and use it in GitHub Desktop.
test-pytimeparse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
print("https://github.com/wroberts/pytimeparse/pull/14") | |
values = ["-%s seconds" % i for i in xrange(10)] | |
valuesbig = ["-%s seconds" % i for i in xrange(100)] | |
valuesbigger = ["-%s seconds" % i for i in xrange(1000)] | |
for v in ["values", "valuesbig", "valuesbigger"]: | |
print(timeit.timeit( | |
"[timeparse(v) for v in %s]" % v, | |
"from pytimeparse.timeparse import timeparse; from __main__ import values, valuesbig, valuesbigger", | |
number=1000 | |
)) | |
print("") | |
print("pandas") | |
for v in ["values", "valuesbig", "valuesbigger"]: | |
print(timeit.timeit( | |
"[pd.to_timedelta(v, box=False) for v in %s]" % v, | |
"import pandas as pd; from __main__ import values, valuesbig, valuesbigger", | |
number=1000 | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
except pd.to_timedelta accepts a list so you don't need to to list comprehension :)