Repository: pandas-dev/pandas

Issue:
BUG: `pd.to_timedelta()` does not accept nullable float
### Pandas version checks

- [X] I have checked that this issue has not already been reported.

- [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas.

- [ ] I have confirmed this bug exists on the main branch of pandas.


### Reproducible Example

```python
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:

```python
pd.to_timedelta(pd.Series([1], dtype="float64"))
```

### Installed Versions

<details>

INSTALLED VERSIONS
------------------
commit           : 87cfe4e38bafe7300a6003a1d18bd80f3f77c763
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

</details>



Discussion:

Patch:
diff --git a/doc/source/whatsnew/v1.6.0.rst b/doc/source/whatsnew/v1.6.0.rst
index 9f793532e5e6b..0c4b5ac88a4ac 100644
--- a/doc/source/whatsnew/v1.6.0.rst
+++ b/doc/source/whatsnew/v1.6.0.rst
@@ -169,7 +169,7 @@ Datetimelike
 
 Timedelta
 ^^^^^^^^^
--
+- Bug in :func:`to_timedelta` raising error when input has nullable dtype ``Float64`` (:issue:`48796`)
 -
 
 Timezones
diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py
index 75e4ab6b37bf7..4c3e790c2879b 100644
--- a/pandas/core/arrays/timedeltas.py
+++ b/pandas/core/arrays/timedeltas.py
@@ -45,6 +45,7 @@
 from pandas.core.dtypes.common import (
     TD64NS_DTYPE,
     is_dtype_equal,
+    is_extension_array_dtype,
     is_float_dtype,
     is_integer_dtype,
     is_object_dtype,
@@ -909,7 +910,11 @@ def sequence_to_td64ns(
     elif is_float_dtype(data.dtype):
         # cast the unit, multiply base/frac separately
         # to avoid precision issues from float -> int
-        mask = np.isnan(data)
+        if is_extension_array_dtype(data):
+            mask = data._mask
+            data = data._data
+        else:
+            mask = np.isnan(data)
         # The next few lines are effectively a vectorized 'cast_from_unit'
         m, p = precision_from_unit(unit or "ns")
         base = data.astype(np.int64)


Test patch:
diff --git a/pandas/tests/tools/test_to_timedelta.py b/pandas/tests/tools/test_to_timedelta.py
index 488e266a1c5c1..13d663474aff0 100644
--- a/pandas/tests/tools/test_to_timedelta.py
+++ b/pandas/tests/tools/test_to_timedelta.py
@@ -278,3 +278,10 @@ def test_to_timedelta_zerodim(self, fixed_now_ts):
         result = to_timedelta(arg2)
         assert isinstance(result, pd.Timedelta)
         assert result.value == dt64.view("i8")
+
+    def test_to_timedelta_numeric_ea(self, any_numeric_ea_dtype):
+        # GH#48796
+        ser = Series([1, pd.NA], dtype=any_numeric_ea_dtype)
+        result = to_timedelta(ser)
+        expected = Series([pd.Timedelta(1, unit="ns"), pd.NaT])
+        tm.assert_series_equal(result, expected)