-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pd.to_datetime, unit='s' much slower for float64 than for int64 #20445
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
Comments
see the logic here: https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/tslib.pyx#L400 for integers of so this is conceptually very easy to fix, but would have to slightly re-factor The reason is you need part 1) to do the calculation. This is all very straightforward, but care must be taken to make sure |
we also likely don't have asv's for this. |
I notice that this has been open for a while - I'm keen to work on this if there's interest! |
Checked that this is still an issue (June 2020). I get %%timeit -r 3
pd.to_datetime(timestamp_seconds_int, unit='s')
44.1 ms ± 12.2 ms per loop (mean ± std. dev. of 3 runs, 10 loops each) %%timeit -r 3
pd.to_datetime(timestamp_seconds_float, unit='s')
15.3 s ± 144 ms per loop (mean ± std. dev. of 3 runs, 1 loop each) Output of pd.versions()INSTALLED VERSIONS ------------------ commit : 97f7918 python : 3.8.3.final.0 python-bits : 64 OS : Linux OS-release : 4.15.0-106-generic Version : #107-Ubuntu SMP Thu Jun 4 11:27:52 UTC 2020 machine : x86_64 processor : byteorder : little LC_ALL : C.UTF-8 LANG : C.UTF-8 LOCALE : en_US.UTF-8pandas : 1.1.0.dev0+1931.g97f791876 I'll work on fixing this following @jreback's comments above, and add the benchmarks. |
Calling
pd.to_datetime
with theunit='s'
kwarg appears to be 1000x slower for float64 than for int64. There does not appear to be a difference in performance between the two types if the timestamps are first converted to nanoseconds and no unit is specified.Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Darwin
OS-release: 17.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.23.0.dev0+658.g17c1fadb0
pytest: 3.0.6
pip: 9.0.3
setuptools: 38.5.2
Cython: 0.28.1
numpy: 1.14.1
scipy: 1.0.0
pyarrow: 0.8.0
xarray: 0.10.0
IPython: 6.2.1
sphinx: None
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2016.10
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
sqlalchemy: 1.1.10
pymysql: None
psycopg2: 2.7.1 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: