Skip to content

DOC: timezone conversion example added to pandas.Series.astype doc #33399 #33470

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

Merged
merged 5 commits into from
Apr 12, 2020
18 changes: 18 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5538,6 +5538,24 @@ def astype(
0 10
1 2
dtype: int64

Create a series of dates:

>>> ser_date = pd.Series(pd.date_range('20200101', periods=3))
>>> ser_date
0 2020-01-01
1 2020-01-02
2 2020-01-03
dtype: datetime64[ns]

Convert to datetime type with time zone:

>>> # localize to UTC and convert to US/Eastern time zone
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the comment here, can you add it as commentary with Convert to datetime type with time zone:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @mroeschke

I'll make that change and update the PR.

>>> ser_date.astype('datetime64[ns, US/Eastern]')
0 2019-12-31 19:00:00-05:00
1 2020-01-01 19:00:00-05:00
2 2020-01-02 19:00:00-05:00
dtype: datetime64[ns, US/Eastern]
"""
if is_dict_like(dtype):
if self.ndim == 1: # i.e. Series
Expand Down