Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
>>> import pandas as pd
>>> sr = pd.Series([10, 20, 30], dtype='timedelta64[ns]')
>>> sr
0 00:00:00.000000
1 00:00:00.000000
2 00:00:00.000000
dtype: timedelta64[ns]
>>> sr = pd.Series([1000, 20, 30], dtype='timedelta64[ns]')
>>> sr
0 00:00:00.000001
1 00:00:00.000000
2 00:00:00.000000
dtype: timedelta64[ns]
>>> sr = pd.Series([1000, 222330, 30], dtype='timedelta64[ns]')
>>> sr
0 00:00:00.000001
1 00:00:00.000222
2 00:00:00.000000
dtype: timedelta64[ns]
>>> sr1 = pd.Series([1000, 222330, None], dtype='timedelta64[ns]')
>>> sr1
0 00:00:00.000001
1 00:00:00.000222
2 NaT
dtype: timedelta64[ns]
>>> sr / sr1
0 1.0
1 1.0
2 NaN
dtype: float64
>>> sr // sr1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nvme/0/pgali/envs/cudfdev1/lib/python3.7/site-packages/pandas/core/ops/common.py", line 64, in new_method
return method(self, other)
File "/nvme/0/pgali/envs/cudfdev1/lib/python3.7/site-packages/pandas/core/ops/__init__.py", line 503, in wrapper
result = arithmetic_op(lvalues, rvalues, op, str_rep)
File "/nvme/0/pgali/envs/cudfdev1/lib/python3.7/site-packages/pandas/core/ops/array_ops.py", line 193, in arithmetic_op
res_values = dispatch_to_extension_op(op, lvalues, rvalues)
File "/nvme/0/pgali/envs/cudfdev1/lib/python3.7/site-packages/pandas/core/ops/dispatch.py", line 125, in dispatch_to_extension_op
res_values = op(left, right)
File "/nvme/0/pgali/envs/cudfdev1/lib/python3.7/site-packages/pandas/core/arrays/timedeltas.py", line 637, in __floordiv__
result[mask] = np.nan
ValueError: cannot convert float NaN to integer
Problem description
When there is a NaT
in either of the series, the result should ideally be of type nullable
integer (Int64
) to avoid this kind of ValueError
Expected Output
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.6.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-76-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.5
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 49.1.0.post20200704
Cython : 0.29.21
pytest : 5.4.3
hypothesis : 5.19.0
sphinx : 3.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.17.1
pytables : None
pytest : 5.4.3
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : 0.50.1