-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Description
Code Sample, a copy-pastable example if possible
In[40]: df = pd.DataFrame([[0]], dtype="datetime64[ns]")
In[46]: df[0] - pd.to_datetime("nat")
Out[47]:
0 NaT
Name: 0, dtype: datetime64[ns]
In[47]: df[0] - pd.to_datetime("2017")
Out[48]:
0 -17167 days
Name: 0, dtype: timedelta64[ns]
Problem description
Operation - on datetimes should always return a timedelta.
Output of pd.show_versions()
[paste the output of pd.show_versions()
here below this line]
INSTALLED VERSIONS
commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.10.0-35-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.20.3
pytest: None
pip: 9.0.1
setuptools: 36.2.7
Cython: None
numpy: 1.13.3
scipy: 0.19.0
xarray: None
IPython: 6.0.0
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999999999
sqlalchemy: 1.1.14
pymysql: None
psycopg2: 2.7.3 (dt dec pq3 ext lo64)
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None
Activity
michalsustr commentedon Oct 10, 2017
This seems like an easy issue to fix, I can create a PR if this is indeed confirmed.
chris-b1 commentedon Oct 10, 2017
Can you try on master? There's a chance this is fixed by some of the recent inference changes, if it isn't not a PR would be welcome
michalsustr commentedon Oct 10, 2017
I'm building it now... but
$ python setup.py develop
is super slow, runs only one process...michalsustr commentedon Oct 10, 2017
Confirmed.
Output of
pd.show_versions()
:pandas: 0.21.0.dev+613.gd12a7a018
pytest: 3.2.3
pip: 9.0.1
setuptools: 36.5.0
Cython: 0.27.1
numpy: 1.13.3
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
michalsustr commentedon Oct 11, 2017
Strangely, the following works correctly:
michalsustr commentedon Oct 11, 2017
So it seems that if the datetime is inside of
Series
the behaviour is correct, but if it is a scalar value improper type is casted:jreback commentedon Oct 13, 2017
@michalsustr what do you think is wrong here?
jaksmid commentedon Dec 7, 2017
It seems the issue is now fixed, at least for pandas
0.20.3
.jreback commentedon Dec 7, 2017
can u do a PR with some validation tests?
2 remaining items