@@ -567,6 +567,8 @@ def tz(self) -> tzinfo | None:
567
567
568
568
Examples
569
569
--------
570
+ For Series:
571
+
570
572
>>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
571
573
>>> s = pd.to_datetime(s)
572
574
>>> s
@@ -575,6 +577,13 @@ def tz(self) -> tzinfo | None:
575
577
dtype: datetime64[ns, UTC]
576
578
>>> s.dt.tz
577
579
datetime.timezone.utc
580
+
581
+ For DatetimeIndex:
582
+
583
+ >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
584
+ ... "2/1/2020 11:00:00+00:00"])
585
+ >>> idx.tz
586
+ datetime.timezone.utc
578
587
"""
579
588
# GH 18595
580
589
return getattr (self .dtype , "tz" , None )
@@ -1326,6 +1335,8 @@ def time(self) -> npt.NDArray[np.object_]:
1326
1335
1327
1336
Examples
1328
1337
--------
1338
+ For Series:
1339
+
1329
1340
>>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
1330
1341
>>> s = pd.to_datetime(s)
1331
1342
>>> s
@@ -1336,6 +1347,13 @@ def time(self) -> npt.NDArray[np.object_]:
1336
1347
0 10:00:00
1337
1348
1 11:00:00
1338
1349
dtype: object
1350
+
1351
+ For DatetimeIndex:
1352
+
1353
+ >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
1354
+ ... "2/1/2020 11:00:00+00:00"])
1355
+ >>> idx.time
1356
+ array([datetime.time(10, 0), datetime.time(11, 0)], dtype=object)
1339
1357
"""
1340
1358
# If the Timestamps have a timezone that is not UTC,
1341
1359
# convert them into their i8 representation while
@@ -1353,6 +1371,8 @@ def timetz(self) -> npt.NDArray[np.object_]:
1353
1371
1354
1372
Examples
1355
1373
--------
1374
+ For Series:
1375
+
1356
1376
>>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
1357
1377
>>> s = pd.to_datetime(s)
1358
1378
>>> s
@@ -1363,6 +1383,14 @@ def timetz(self) -> npt.NDArray[np.object_]:
1363
1383
0 10:00:00+00:00
1364
1384
1 11:00:00+00:00
1365
1385
dtype: object
1386
+
1387
+ For DatetimeIndex:
1388
+
1389
+ >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
1390
+ ... "2/1/2020 11:00:00+00:00"])
1391
+ >>> idx.timetz
1392
+ array([datetime.time(10, 0, tzinfo=datetime.timezone.utc),
1393
+ datetime.time(11, 0, tzinfo=datetime.timezone.utc)], dtype=object)
1366
1394
"""
1367
1395
return ints_to_pydatetime (self .asi8 , self .tz , box = "time" , reso = self ._creso )
1368
1396
@@ -1376,6 +1404,8 @@ def date(self) -> npt.NDArray[np.object_]:
1376
1404
1377
1405
Examples
1378
1406
--------
1407
+ For Series:
1408
+
1379
1409
>>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
1380
1410
>>> s = pd.to_datetime(s)
1381
1411
>>> s
@@ -1386,6 +1416,13 @@ def date(self) -> npt.NDArray[np.object_]:
1386
1416
0 2020-01-01
1387
1417
1 2020-02-01
1388
1418
dtype: object
1419
+
1420
+ For DatetimeIndex:
1421
+
1422
+ >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
1423
+ ... "2/1/2020 11:00:00+00:00"])
1424
+ >>> idx.date
1425
+ array([datetime.date(2020, 1, 1), datetime.date(2020, 2, 1)], dtype=object)
1389
1426
"""
1390
1427
# If the Timestamps have a timezone that is not UTC,
1391
1428
# convert them into their i8 representation while
@@ -1667,6 +1704,8 @@ def isocalendar(self) -> DataFrame:
1667
1704
1668
1705
Examples
1669
1706
--------
1707
+ For Series:
1708
+
1670
1709
>>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
1671
1710
>>> s = pd.to_datetime(s)
1672
1711
>>> s
@@ -1677,6 +1716,13 @@ def isocalendar(self) -> DataFrame:
1677
1716
0 1
1678
1717
1 32
1679
1718
dtype: int32
1719
+
1720
+ For DatetimeIndex:
1721
+
1722
+ >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
1723
+ ... "2/1/2020 11:00:00+00:00"])
1724
+ >>> idx.dayofyear
1725
+ Index([1, 32], dtype='int32')
1680
1726
""" ,
1681
1727
)
1682
1728
dayofyear = day_of_year
@@ -1688,6 +1734,8 @@ def isocalendar(self) -> DataFrame:
1688
1734
1689
1735
Examples
1690
1736
--------
1737
+ For Series:
1738
+
1691
1739
>>> s = pd.Series(["1/1/2020 10:00:00+00:00", "4/1/2020 11:00:00+00:00"])
1692
1740
>>> s = pd.to_datetime(s)
1693
1741
>>> s
@@ -1698,6 +1746,13 @@ def isocalendar(self) -> DataFrame:
1698
1746
0 1
1699
1747
1 2
1700
1748
dtype: int32
1749
+
1750
+ For DatetimeIndex:
1751
+
1752
+ >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
1753
+ ... "2/1/2020 11:00:00+00:00"])
1754
+ >>> idx.quarter
1755
+ Index([1, 1], dtype='int32')
1701
1756
""" ,
1702
1757
)
1703
1758
days_in_month = _field_accessor (
0 commit comments