Skip to content

Timedeltas cast as datetime in DataFrames #15560

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
nbonnotte opened this issue Mar 3, 2017 · 3 comments
Closed

Timedeltas cast as datetime in DataFrames #15560

nbonnotte opened this issue Mar 3, 2017 · 3 comments
Labels
Bug Datetime Datetime data dtype Duplicate Report Duplicate issue or pull request Timedelta Timedelta data type

Comments

@nbonnotte
Copy link
Contributor

Code Sample, a copy-pastable example if possible

In [10]: pandas.DataFrame([[datetime.datetime(2017, 1, 1)]]) - datetime.datetime(2001, 1, 1)
Out[10]: 
           0
0 1986-01-01

In [11]: pandas.Series([datetime.datetime(2017, 1, 1)]) - datetime.datetime(2001, 1, 1)
Out[11]: 
0   5844 days
dtype: timedelta64[ns]

Problem description

For dataframe, the value "5844 days" is cast as a datetime, so it becomes "1970-01-01 + 5844 days = 1986-01-01"

Expected Output

In [10]: pandas.DataFrame([[datetime.datetime(2017, 1, 1)]]) - datetime.datetime(2001, 1, 1)
Out[10]:
0
0 5844 days

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: 211ecd5 python: 2.7.11.final.0 python-bits: 64 OS: Linux OS-release: 4.4.0-59-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: None.None

pandas: 0.19.0+527.g211ecd5
pytest: 3.0.6
pip: 9.0.1
setuptools: 22.0.0
Cython: 0.24
numpy: 1.11.0
scipy: 0.17.1
xarray: None
IPython: 4.2.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.4
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: None
s3fs: None
pandas_gbq: None
pandas_datareader: None

@chris-b1 chris-b1 added Bug Timedelta Timedelta data type Datetime Datetime data dtype labels Mar 3, 2017
@chris-b1 chris-b1 added this to the Next Major Release milestone Mar 3, 2017
@chris-b1
Copy link
Contributor

chris-b1 commented Mar 3, 2017

Yep, looks buggy.

@jreback
Copy link
Contributor

jreback commented Mar 3, 2017

yes, but dupe of this: #8554

@jreback jreback closed this as completed Mar 3, 2017
@jreback
Copy link
Contributor

jreback commented Mar 3, 2017

of course PR's to fix welcome!

@jreback jreback added the Duplicate Report Duplicate issue or pull request label Mar 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Duplicate Report Duplicate issue or pull request Timedelta Timedelta data type
Projects
None yet
Development

No branches or pull requests

3 participants