Skip to content

COMPAT: force int when doing unit conversions in pd.to_datetime #11760

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
jreback opened this issue Dec 4, 2015 · 2 comments
Closed

COMPAT: force int when doing unit conversions in pd.to_datetime #11760

jreback opened this issue Dec 4, 2015 · 2 comments
Labels
Compat pandas objects compatability with Numpy or Python functions Datetime Datetime data dtype

Comments

@jreback
Copy link
Contributor

jreback commented Dec 4, 2015

from SO
xref to #11758

We should force int conversions when unit is passed (as by definition these are int-like things).

In [21]: s = pd.Series(["1440643875", "1440644191", "1440645638", "1440998720"], dtype=object)

In [22]: pd.to_datetime(s,unit='s')
ValueError: year is out of range

In [23]: pd.to_datetime(s.astype(int),unit='s')
Out[23]: 
0   2015-08-27 02:51:15
1   2015-08-27 02:56:31
2   2015-08-27 03:20:38
3   2015-08-31 05:25:20
dtype: datetime64[ns]
@jreback jreback added Datetime Datetime data dtype Difficulty Novice Compat pandas objects compatability with Numpy or Python functions labels Dec 4, 2015
@jreback jreback added this to the Next Major Release milestone Dec 4, 2015
@gliptak
Copy link
Contributor

gliptak commented May 8, 2016

This seem to have been corrected in current HEAD:

In [5]: s = pd.Series(["1440643875", "1440644191", "1440645638", "1440998720"], dtype=object)

In [6]: pd.to_datetime(s,unit='s')
Out[6]: 
0   2015-08-27 02:51:15
1   2015-08-27 02:56:31
2   2015-08-27 03:20:38
3   2015-08-31 05:25:20
dtype: datetime64[ns]

@jreback
Copy link
Contributor Author

jreback commented May 8, 2016

this was closed by #13003 and is already sufficiently tested.

@jreback jreback closed this as completed May 8, 2016
@jreback jreback modified the milestones: No action, Next Major Release May 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Datetime Datetime data dtype
Projects
None yet
Development

No branches or pull requests

2 participants