@@ -54,7 +54,6 @@ from offsets import _Tick
54
54
55
55
cdef bint PY2 = str == bytes
56
56
57
-
58
57
cdef extern from " period_helper.h" :
59
58
int FR_ANN
60
59
int FR_QTR
@@ -1380,41 +1379,105 @@ cdef class _Period(object):
1380
1379
@property
1381
1380
def dayofweek (self ):
1382
1381
"""
1383
- Return the day of the week.
1382
+ Day of the week the period lies in, with Monday=0 and Sunday=6.
1383
+
1384
+ If the period frequency is lower than daily (e.g. hourly), and the
1385
+ period spans over multiple days, the day at the start of the period is
1386
+ used.
1384
1387
1385
- This attribute returns the day of the week on which the particular
1386
- date for the given period occurs depending on the frequency with
1387
- Monday=0, Sunday=6.
1388
+ If the frequency is higher than daily (e.g. monthly), the last day
1389
+ of the period is used.
1388
1390
1389
1391
Returns
1390
1392
-------
1391
- Int
1392
- Range from 0 to 6 (included) .
1393
+ int
1394
+ Day of the week .
1393
1395
1394
- See also
1396
+ See Also
1395
1397
--------
1396
- Period.dayofyear : Return the day of the year.
1397
- Period.daysinmonth : Return the number of days in that month.
1398
+ Period.dayofweek : Day of the week the period lies in.
1399
+ Period.weekday : Alias of Period.dayofweek.
1400
+ Period.day : Day of the month.
1401
+ Period.dayofyear : Day of the year.
1398
1402
1399
1403
Examples
1400
1404
--------
1401
- >>> period1 = pd.Period('2012-1-1 19:00', freq='H')
1402
- >>> period1
1403
- Period('2012-01-01 19:00', 'H')
1404
- >>> period1.dayofweek
1405
+ >>> per = pd.Period('2017-12-31 22:00', 'H')
1406
+ >>> per.dayofweek
1407
+ 6
1408
+
1409
+ For periods that span over multiple days, the day at the beginning of
1410
+ the period is returned.
1411
+
1412
+ >>> per = pd.Period('2017-12-31 22:00', '4H')
1413
+ >>> per.dayofweek
1414
+ 6
1415
+ >>> per.start_time.dayofweek
1405
1416
6
1406
1417
1407
- >>> period2 = pd.Period('2013-1-9 11:00', freq='H')
1408
- >>> period2
1409
- Period('2013-01-09 11:00', 'H')
1410
- >>> period2.dayofweek
1418
+ For periods with a frequency higher than days, the last day of the
1419
+ period is returned.
1420
+
1421
+ >>> per = pd.Period('2018-01', 'M')
1422
+ >>> per.dayofweek
1423
+ 2
1424
+ >>> per.end_time.dayofweek
1411
1425
2
1412
1426
"""
1413
1427
base, mult = get_freq_code(self .freq)
1414
1428
return pweekday(self .ordinal, base)
1415
1429
1416
1430
@property
1417
1431
def weekday (self ):
1432
+ """
1433
+ Day of the week the period lies in, with Monday=0 and Sunday=6.
1434
+
1435
+ If the period frequency is lower than daily (e.g. hourly), and the
1436
+ period spans over multiple days, the day at the start of the period is
1437
+ used.
1438
+
1439
+ If the frequency is higher than daily (e.g. monthly), the last day
1440
+ of the period is used.
1441
+
1442
+ Returns
1443
+ -------
1444
+ int
1445
+ Day of the week.
1446
+
1447
+ See Also
1448
+ --------
1449
+ Period.dayofweek : Day of the week the period lies in.
1450
+ Period.weekday : Alias of Period.dayofweek.
1451
+ Period.day : Day of the month.
1452
+ Period.dayofyear : Day of the year.
1453
+
1454
+ Examples
1455
+ --------
1456
+ >>> per = pd.Period('2017-12-31 22:00', 'H')
1457
+ >>> per.dayofweek
1458
+ 6
1459
+
1460
+ For periods that span over multiple days, the day at the beginning of
1461
+ the period is returned.
1462
+
1463
+ >>> per = pd.Period('2017-12-31 22:00', '4H')
1464
+ >>> per.dayofweek
1465
+ 6
1466
+ >>> per.start_time.dayofweek
1467
+ 6
1468
+
1469
+ For periods with a frequency higher than days, the last day of the
1470
+ period is returned.
1471
+
1472
+ >>> per = pd.Period('2018-01', 'M')
1473
+ >>> per.dayofweek
1474
+ 2
1475
+ >>> per.end_time.dayofweek
1476
+ 2
1477
+ """
1478
+ # Docstring is a duplicate from dayofweek. Reusing docstrings with
1479
+ # Appender doesn't work for properties in Cython files, and setting
1480
+ # the __doc__ attribute is also not possible.
1418
1481
return self .dayofweek
1419
1482
1420
1483
@property
0 commit comments