Skip to content

BUG: pd.to_timedelta() does not accept nullable float #48796

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
2 of 3 tasks
davidchall opened this issue Sep 26, 2022 · 0 comments · Fixed by #48854
Closed
2 of 3 tasks

BUG: pd.to_timedelta() does not accept nullable float #48796

davidchall opened this issue Sep 26, 2022 · 0 comments · Fixed by #48854
Labels
Bug NA - MaskedArrays Related to pd.NA and nullable extension arrays Timedelta Timedelta data type

Comments

@davidchall
Copy link
Contributor

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
pd.to_timedelta(pd.Series([1], dtype="Float64"))

Issue Description

The pd.to_timedelta() function does not accept a series using the nullable float extension dtype (either "Float32" or "Float64").

An exception is raised with the following message:

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

Expected Behavior

In this example, I would expect the output to be the same as for the regular NumPy dtype:

pd.to_timedelta(pd.Series([1], dtype="float64"))

Installed Versions

INSTALLED VERSIONS

commit : 87cfe4e
python : 3.9.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 1.5.0
numpy : 1.21.5
pytz : 2022.1
dateutil : 2.8.2
setuptools : 63.4.1
pip : 22.1.2
Cython : 0.29.30
pytest : 7.1.2
hypothesis : None
sphinx : 5.0.2
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : 4.9.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 8.4.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : 1.3.5
brotli :
fastparquet : None
fsspec : 2022.7.1
gcsfs : None
matplotlib : 3.5.2
numba : 0.55.1
numexpr : 2.8.3
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.1
snappy :
sqlalchemy : 1.4.39
tables : 3.6.1
tabulate : 0.8.10
xarray : 0.20.1
xlrd : 2.0.1
xlwt : None
zstandard : None
tzdata : None

@davidchall davidchall added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 26, 2022
@phofl phofl added Timedelta Timedelta data type NA - MaskedArrays Related to pd.NA and nullable extension arrays and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug NA - MaskedArrays Related to pd.NA and nullable extension arrays Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants