pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.67k stars 17.91k forks source link

DOC: See also box should refer to same type (Series.dt.tz_convert --> Series.dt.tz_localize) #49297

Open NumesSanguis opened 2 years ago

NumesSanguis commented 2 years ago

Pandas version checks

Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.Series.dt.tz_convert.html

Documentation problem

The "See also" would be more useful if it refers to the same type. While the mentioned page is about Series, the "See also" refers to DatetimeIndex.

I was looking to remove timezone information from a tz-aware Datetime Array without converting to UTC. I landed on the linked documentation page (which includes converting to UTC). The "See also" made me aware of the function tz_convert. Assuming the page was still about a Pandas series, I applied the suggest approach, but ran into an error with my_series.tz_localize(None). For Pandas Series, it has to be my_series.dt.tz_localize(None) (with .dt.).

Suggested fix for documentation

pandas.Series.dt.tz_convert "See also" box should refer to:

Rather than the current:

DatetimeIndex.tz

  • A timezone that has a variable offset from UTC.

DatetimeIndex.tz_localize

  • Localize tz-naive DatetimeIndex to a given time zone, or remove timezone from a tz-aware DatetimeIndex.
wheatonaaron commented 1 year ago

take