Skip to content

DOC: update the Period.qyear docstring #20333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,45 @@ cdef class _Period(object):

@property
def qyear(self):
"""
Fiscal year the Period lies in according to its starting-quarter.

The `year` and the `qyear` of the period will be the same if the fiscal
and calendar years are the same. When they are not, the fiscal year
can be different from the calendar year of the period.

Returns
-------
int
The fiscal year of the period.

See Also
--------
Period.year : Return the calendar year of the period.

Examples
--------
If the natural and fiscal year are the same, `qyear` and `year` will
be the same.

>>> per = pd.Period('2018Q1', freq='Q')
>>> per.qyear
2018
>>> per.year
2018

If the fiscal year starts in April (`Q-MAR`), the first quarter of
2018 will start in April 2017. `year` will then be 2018, but `qyear`
will be the fiscal year, 2018.

>>> per = pd.Period('2018Q1', freq='Q-MAR')
>>> per.start_time
Timestamp('2017-04-01 00:00:00')
>>> per.qyear
2018
>>> per.year
2017
"""
base, mult = get_freq_code(self.freq)
return pqyear(self.ordinal, base)

Expand Down