Skip to content
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

pandas.Timestamp with time only string doesn't work #16074

Closed
ceacar opened this issue Apr 20, 2017 · 3 comments
Closed

pandas.Timestamp with time only string doesn't work #16074

ceacar opened this issue Apr 20, 2017 · 3 comments
Labels
Datetime Datetime data dtype Duplicate Report Duplicate issue or pull request

Comments

@ceacar
Copy link

ceacar commented Apr 20, 2017

Code Sample, a copy-pastable example if possible

In [147]: pandas.Timestamp('4 pm')
---------------------------------------------------------------------------
OutOfBoundsDatetime                       Traceback (most recent call last)
<ipython-input-147-333a3814fcab> in <module>()
----> 1 pandas.Timestamp('4 pm')

pandas/tslib.pyx in pandas.tslib.Timestamp.__new__ (pandas/tslib.c:10447)()

pandas/tslib.pyx in pandas.tslib.convert_to_tsobject (pandas/tslib.c:27555)()

pandas/tslib.pyx in pandas.tslib.convert_str_to_tsobject (pandas/tslib.c:29955)()

pandas/tslib.pyx in pandas.tslib.convert_to_tsobject (pandas/tslib.c:28700)()

pandas/tslib.pyx in pandas.tslib._check_dts_bounds (pandas/tslib.c:32835)()

OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 1-01-01 16:00:00

Problem description

this type of string conversion doesn't work with 0.19.2 since upgrade from 0.16.0
traced the problem using git bisect to this commit:
c2ea0d4

Expected Output

In [3]: pandas.Timestamp('4 pm')
Out[3]: Timestamp('2017-04-20 16:00:00')

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 2.7.6.final.0 python-bits: 64 OS: Linux OS-release: 3.13.0-112-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: None.None

pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 34.3.3
Cython: None
numpy: 1.11.2
scipy: None
statsmodels: None
xarray: None
IPython: 5.3.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None

@jreback
Copy link
Contributor

jreback commented Apr 20, 2017

so the error message is obviously wrong, but what should this actually do? Sure you can return today's date, but generally this indicates an error (and is certainly not explicitly reproducible). I would much rather people be explicit about this.

@jreback jreback added Needs Discussion Requires discussion from core team before further action Datetime Datetime data dtype labels Apr 20, 2017
@jorisvandenbossche
Copy link
Member

So the PR on github I linked to seems to be the correct one. As I said there, the PR's intent was to parse something like Timestamp('2012') no longer by filling with current month and day of the month, but setting it to 2012-01-01 (and to make this consistent over the different the different parsing functions we have in pandas).
So that change was certainly intentional. The change that, when only supplying a time part, the date part is no longer filled with the current date, but with 0001-01-01, is possibly a side-effect we maybe didn't fully catch then.

@jorisvandenbossche
Copy link
Member

OK, it is not that clear actually, as other time-only string do work:

In [16]: pd.Timestamp("16:15")
Out[16]: Timestamp('2017-04-21 16:15:00')

In [17]: pd.to_datetime("16:15")
Out[17]: Timestamp('2017-04-21 16:15:00')

But, this is a duplicate of #11430, so let's move the discussion over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

3 participants