From 837f7f8ff85c31ccfa422f2a7673be07f83ed4b5 Mon Sep 17 00:00:00 2001 From: Tuhin Sharma Date: Sat, 31 Aug 2024 10:45:54 +0530 Subject: [PATCH] DOC: fix PR01,SA01 for pandas.Period.strftime --- ci/code_checks.sh | 1 - pandas/_libs/tslibs/period.pyx | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 2f95367266a36..bb3ceded880f4 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -73,7 +73,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.NA SA01" \ -i "pandas.Period.freq GL08" \ -i "pandas.Period.ordinal GL08" \ - -i "pandas.Period.strftime PR01,SA01" \ -i "pandas.Period.to_timestamp SA01" \ -i "pandas.PeriodDtype SA01" \ -i "pandas.PeriodDtype.freq SA01" \ diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index b3f06565c7789..e4771feeb804e 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -2755,6 +2755,27 @@ cdef class _Period(PeriodMixin): | ``%%`` | A literal ``'%'`` character. | | +-----------+--------------------------------+-------+ + The `strftime` method provides a way to represent a :class:`Period` + object as a string in a specified format. This is particularly useful + when displaying date and time data in different locales or customized + formats, suitable for reports or user interfaces. It extends the standard + Python string formatting capabilities with additional directives specific + to `pandas`, accommodating features like fiscal years and precise + sub-second components. + + Parameters + ---------- + fmt : str or None + String containing the desired format directives. If ``None``, the + format is determined based on the Period's frequency. + + See Also + -------- + Timestamp.strftime : Return a formatted string of the Timestamp. + to_datetime : Convert argument to datetime. + time.strftime : Format a time object as a string according to a + specified format string in the standard Python library. + Notes -----