Skip to content

Commit 486bfe8

Browse files
uttamaniketdatapythonista
authored andcommitted
DOC: update the Period.qyear docstring (pandas-dev#20333)
* DOC: update the Period.qyear docstring * DOC: update the Period.qyear docstring * DOC: update the Period.qyear docstring * DOC: update the Period.qyear docstring * update qyear Signed-off-by: uttamaniket <[email protected]> * update qyear Signed-off-by: uttamaniket <[email protected]> * update qyear Signed-off-by: uttamaniket <[email protected]> * update qyear Signed-off-by: uttamaniket <[email protected]> * update Period.qyear Signed-off-by: uttamaniket <[email protected]> * update Period.qyear Signed-off-by: uttamaniket <[email protected]> * update pandas.qyear Signed-off-by: uttamaniket <[email protected]> * update qyear Signed-off-by: uttamaniket <[email protected]> * Adding extra clarification on how year and qyear are different * Addressing last comments from @jbrockmendel
1 parent ec07ea8 commit 486bfe8

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

pandas/_libs/tslibs/period.pyx

+39
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,45 @@ cdef class _Period(object):
14631463

14641464
@property
14651465
def qyear(self):
1466+
"""
1467+
Fiscal year the Period lies in according to its starting-quarter.
1468+
1469+
The `year` and the `qyear` of the period will be the same if the fiscal
1470+
and calendar years are the same. When they are not, the fiscal year
1471+
can be different from the calendar year of the period.
1472+
1473+
Returns
1474+
-------
1475+
int
1476+
The fiscal year of the period.
1477+
1478+
See Also
1479+
--------
1480+
Period.year : Return the calendar year of the period.
1481+
1482+
Examples
1483+
--------
1484+
If the natural and fiscal year are the same, `qyear` and `year` will
1485+
be the same.
1486+
1487+
>>> per = pd.Period('2018Q1', freq='Q')
1488+
>>> per.qyear
1489+
2018
1490+
>>> per.year
1491+
2018
1492+
1493+
If the fiscal year starts in April (`Q-MAR`), the first quarter of
1494+
2018 will start in April 2017. `year` will then be 2018, but `qyear`
1495+
will be the fiscal year, 2018.
1496+
1497+
>>> per = pd.Period('2018Q1', freq='Q-MAR')
1498+
>>> per.start_time
1499+
Timestamp('2017-04-01 00:00:00')
1500+
>>> per.qyear
1501+
2018
1502+
>>> per.year
1503+
2017
1504+
"""
14661505
base, mult = get_freq_code(self.freq)
14671506
return pqyear(self.ordinal, base)
14681507

0 commit comments

Comments
 (0)