We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 610568c commit e6b9004Copy full SHA for e6b9004
pandas/core/generic.py
@@ -5538,6 +5538,24 @@ def astype(
5538
0 10
5539
1 2
5540
dtype: int64
5541
+
5542
+ Create a series of dates:
5543
5544
+ >>> ser_date = pd.Series(pd.date_range('20200101', periods=3))
5545
+ >>> ser_date
5546
+ 0 2020-01-01
5547
+ 1 2020-01-02
5548
+ 2 2020-01-03
5549
+ dtype: datetime64[ns]
5550
5551
+ Convert to datetime type with time zone:
5552
5553
+ >>> # localize to UTC and convert to US/Eastern time zone
5554
+ >>> ser_date.astype('datetime64[ns, US/Eastern]')
5555
+ 0 2019-12-31 19:00:00-05:00
5556
+ 1 2020-01-01 19:00:00-05:00
5557
+ 2 2020-01-02 19:00:00-05:00
5558
+ dtype: datetime64[ns, US/Eastern]
5559
"""
5560
if is_dict_like(dtype):
5561
if self.ndim == 1: # i.e. Series
0 commit comments