Skip to content

Commit b3580c1

Browse files
DOC: timezone conversion example added to pandas.Series.astype doc #33399 (#33470)
* DOC: timezone conversion example added to pandas.Series.astype doc #33399 * DOC: fixed the whitespace issue flagged in pep8 checks #33399 * DOC: added text in comments to commentary in example #333999 * DOC: added a more generic behavior statement as suggested. #33399 * DOC: removed unwanted commentary statement as per suggestion #33399 Co-authored-by: Venkatesh Datta <[email protected]>
1 parent 03b510c commit b3580c1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/core/generic.py

+18
Original file line numberDiff line numberDiff line change
@@ -5545,6 +5545,24 @@ def astype(
55455545
0 10
55465546
1 2
55475547
dtype: int64
5548+
5549+
Create a series of dates:
5550+
5551+
>>> ser_date = pd.Series(pd.date_range('20200101', periods=3))
5552+
>>> ser_date
5553+
0 2020-01-01
5554+
1 2020-01-02
5555+
2 2020-01-03
5556+
dtype: datetime64[ns]
5557+
5558+
Datetimes are localized to UTC first before
5559+
converting to the specified timezone:
5560+
5561+
>>> ser_date.astype('datetime64[ns, US/Eastern]')
5562+
0 2019-12-31 19:00:00-05:00
5563+
1 2020-01-01 19:00:00-05:00
5564+
2 2020-01-02 19:00:00-05:00
5565+
dtype: datetime64[ns, US/Eastern]
55485566
"""
55495567
if is_dict_like(dtype):
55505568
if self.ndim == 1: # i.e. Series

0 commit comments

Comments
 (0)