Skip to content

"Cannot convert tz-naive timestamps" #9865

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
vfilimonov opened this issue Apr 12, 2015 · 6 comments
Closed

"Cannot convert tz-naive timestamps" #9865

vfilimonov opened this issue Apr 12, 2015 · 6 comments
Labels
Docs Timezones Timezone data dtype
Milestone

Comments

@vfilimonov
Copy link
Contributor

I'm not sure if it is an issue of DOCs or code.

Docs say that tz_convert "Convert the axis to target time zone. If it is time zone naive, it will be localized to the passed time zone."

But the code in contrast raises an exception:

tmp = pd.Series([0], index=[pd.Timestamp('2008-12-16 13:10:00')])
tmp.tz_convert('UTC')

Results in TypeError: Cannot convert tz-naive timestamps, use tz_localize to localize

@jorisvandenbossche
Copy link
Member

I think it is a docs thing. Also the docs on DatetimeIndex.tz_convert are correct in that way: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DatetimeIndex.tz_convert.html#pandas.DatetimeIndex.tz_convert

@jreback correct?

@jorisvandenbossche jorisvandenbossche added this to the 0.16.1 milestone Apr 13, 2015
@jreback
Copy link
Contributor

jreback commented Apr 13, 2015

yeh, this is just an old/not updated doc-string. This will only convert if it is already non-naive, while tz_localize only will work if its naive. This is the original API, and was separate on purpose to prevent non-explict conversions.

want to do a PR to update the doc-strings (maybe add a Raises section to both of these functions in tseries/index.py as well as the functions in core/generic.py

@jreback jreback added the Timezones Timezone data dtype label Apr 13, 2015
@vfilimonov
Copy link
Contributor Author

Sure, will do docs.

@jreback , what do you mean by Raises section?

@jorisvandenbossche
Copy link
Member

@vfilimonov
Copy link
Contributor Author

OK, will do

jorisvandenbossche added a commit that referenced this issue Apr 15, 2015
Fix of the docs for tz_conver and tz_localize (fix for #9865)
@jorisvandenbossche
Copy link
Member

Closed by #9906

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Timezones Timezone data dtype
Projects
None yet
Development

No branches or pull requests

3 participants