Skip to content

pd.to_datetime('today') and pd.Timestamp('today') return different results #19935

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
skaae opened this issue Feb 28, 2018 · 6 comments · Fixed by #19937
Closed

pd.to_datetime('today') and pd.Timestamp('today') return different results #19935

skaae opened this issue Feb 28, 2018 · 6 comments · Fixed by #19937
Labels
Bug Datetime Datetime data dtype
Milestone

Comments

@skaae
Copy link

skaae commented Feb 28, 2018

Code Sample, a copy-pastable example if possible

pd.Timestamp('today')
pd.to_datetime('today')

Problem description

pd.to_datetime('today') returns a floored timestamp and pd.Timestamp('today') doesn't

In [13]: pd.Timestamp('now')
Out[13]: Timestamp('2018-02-28 09:43:20.060483')

In [17]: pd.Timestamp('today')
Out[17]: Timestamp('2018-02-28 09:43:48.628730')

In [19]: pd.to_datetime('today')
Out[19]: Timestamp('2018-02-28 00:00:00')

Expected Output

I would expect pd.Timestamp('today') to behave similarly to pd.to_datetime('today').

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit: None
python: 3.6.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-53-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.22.0
pytest: 3.2.1
pip: 9.0.1
setuptools: 36.5.0.post20170921
Cython: 0.26.1
numpy: 1.13.1
scipy: 0.19.1
pyarrow: 0.8.0
xarray: 0.9.6
IPython: 6.1.0
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: 0.5.0

@jreback
Copy link
Contributor

jreback commented Feb 28, 2018

hmm, yeah this is a bit inconsistent.

cc @jbrockmendel

@jreback jreback added this to the Next Major Release milestone Feb 28, 2018
@jreback
Copy link
Contributor

jreback commented Feb 28, 2018

pull request to fix is welcome!

@shangyian
Copy link
Contributor

shangyian commented Feb 28, 2018

It looks like pandas' Timestamp.today() is modelled after the datetime library's datetime.today(), which returns it with the time component. Does it make sense to have a discrepancy between datetime.today() and Timestamp.today() if the latter gets changed to be a floored datetime?

@jreback
Copy link
Contributor

jreback commented Feb 28, 2018

@shangyian the fix is to change pd.to_datetime for this is hits a different (incorrect path)

@jreback
Copy link
Contributor

jreback commented Feb 28, 2018

this is almost the same issue as #18705 meaning , both are consistent (but incorrect) in .to_datetime

@shangyian
Copy link
Contributor

Ok, that makes more sense now - I added a PR

@jreback jreback modified the milestones: Next Major Release, 0.23.0 Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants