From c62db4d3808d60729e59a041822faf16405f897a Mon Sep 17 00:00:00 2001 From: root Date: Sun, 14 Apr 2019 17:34:45 -0400 Subject: [PATCH 01/10] modified asv_bench/benchmarks/period.py --- asv_bench/benchmarks/period.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asv_bench/benchmarks/period.py b/asv_bench/benchmarks/period.py index 6d2c7156a0a3d..c6c14ee44323d 100644 --- a/asv_bench/benchmarks/period.py +++ b/asv_bench/benchmarks/period.py @@ -8,7 +8,7 @@ class PeriodProperties(object): params = (['M', 'min'], ['year', 'month', 'day', 'hour', 'minute', 'second', 'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth', - 'dayofweek', 'dayofyear', 'start_time', 'end_time']) + 'dayofweek', 'day_of_week','dayofyear', 'start_time', 'end_time']) param_names = ['freq', 'attr'] def setup(self, freq, attr): From 26f7bf7f136662f2fa7fcee9416410b28d831d9b Mon Sep 17 00:00:00 2001 From: hxw Date: Sun, 14 Apr 2019 17:49:05 -0400 Subject: [PATCH 02/10] modified asv_bench/benchmarks/period.py timestamp.py --- asv_bench/benchmarks/period.py | 2 +- asv_bench/benchmarks/timestamp.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/asv_bench/benchmarks/period.py b/asv_bench/benchmarks/period.py index c6c14ee44323d..cc466b3b0baa7 100644 --- a/asv_bench/benchmarks/period.py +++ b/asv_bench/benchmarks/period.py @@ -8,7 +8,7 @@ class PeriodProperties(object): params = (['M', 'min'], ['year', 'month', 'day', 'hour', 'minute', 'second', 'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth', - 'dayofweek', 'day_of_week','dayofyear', 'start_time', 'end_time']) + 'day_of_week','dayofyear', 'start_time', 'end_time']) param_names = ['freq', 'attr'] def setup(self, freq, attr): diff --git a/asv_bench/benchmarks/timestamp.py b/asv_bench/benchmarks/timestamp.py index b45ae22650e17..b0df0d23caf49 100644 --- a/asv_bench/benchmarks/timestamp.py +++ b/asv_bench/benchmarks/timestamp.py @@ -44,7 +44,10 @@ def time_tz(self, tz, freq): self.ts.tz def time_dayofweek(self, tz, freq): - self.ts.dayofweek + self.ts.day_of_week + + def time_day_of_week(self, tz, freq): + self.ts.day_of_week def time_weekday_name(self, tz, freq): self.ts.day_name From 5b62982163608116b3aaa64e6bde5b5a8cd36410 Mon Sep 17 00:00:00 2001 From: hxw Date: Sun, 14 Apr 2019 18:12:54 -0400 Subject: [PATCH 03/10] doc/source/reference/indexing.rst --- doc/source/reference/indexing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index 680cb7e3dac91..9a4060ed9131a 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -352,7 +352,7 @@ Time/Date Components DatetimeIndex.dayofyear DatetimeIndex.weekofyear DatetimeIndex.week - DatetimeIndex.dayofweek + DatetimeIndex.day_of_week DatetimeIndex.weekday DatetimeIndex.quarter DatetimeIndex.tz @@ -451,7 +451,7 @@ Properties :toctree: api/ PeriodIndex.day - PeriodIndex.dayofweek + PeriodIndex.day_of_week PeriodIndex.dayofyear PeriodIndex.days_in_month PeriodIndex.daysinmonth From cdd3f54b211d4bd8ff3ecc40908ec5ee2f3c574a Mon Sep 17 00:00:00 2001 From: hxw Date: Sun, 14 Apr 2019 18:14:46 -0400 Subject: [PATCH 04/10] modified doc/source/reference/series.rst --- doc/source/reference/series.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/reference/series.rst b/doc/source/reference/series.rst index b406893e3414a..6dd2b866a30df 100644 --- a/doc/source/reference/series.rst +++ b/doc/source/reference/series.rst @@ -325,7 +325,7 @@ Datetime Properties Series.dt.nanosecond Series.dt.week Series.dt.weekofyear - Series.dt.dayofweek + Series.dt.day_of_week Series.dt.weekday Series.dt.dayofyear Series.dt.quarter From 356b2663c0e99c6251afd405de825fb418486ae6 Mon Sep 17 00:00:00 2001 From: hxw Date: Sun, 14 Apr 2019 18:20:06 -0400 Subject: [PATCH 05/10] doc/redirects.csv --- doc/redirects.csv | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/redirects.csv b/doc/redirects.csv index a7886779c97d5..cd6aceda68eca 100644 --- a/doc/redirects.csv +++ b/doc/redirects.csv @@ -527,7 +527,8 @@ generated/pandas.DatetimeIndex.ceil,../reference/api/pandas.DatetimeIndex.ceil generated/pandas.DatetimeIndex.date,../reference/api/pandas.DatetimeIndex.date generated/pandas.DatetimeIndex.day,../reference/api/pandas.DatetimeIndex.day generated/pandas.DatetimeIndex.day_name,../reference/api/pandas.DatetimeIndex.day_name -generated/pandas.DatetimeIndex.dayofweek,../reference/api/pandas.DatetimeIndex.dayofweek +generated/pandas.DatetimeIndex.dayofweek,../reference/api/pandas.DatetimeIndex.day_of_week +generated/pandas.DatetimeIndex.day_of_week,../reference/api/pandas.DatetimeIndex.day_of_week generated/pandas.DatetimeIndex.dayofyear,../reference/api/pandas.DatetimeIndex.dayofyear generated/pandas.DatetimeIndex.floor,../reference/api/pandas.DatetimeIndex.floor generated/pandas.DatetimeIndex.freq,../reference/api/pandas.DatetimeIndex.freq @@ -1004,7 +1005,8 @@ generated/pandas.Panel.where,../reference/api/pandas.Panel.where generated/pandas.Panel.xs,../reference/api/pandas.Panel.xs generated/pandas.Period.asfreq,../reference/api/pandas.Period.asfreq generated/pandas.Period.day,../reference/api/pandas.Period.day -generated/pandas.Period.dayofweek,../reference/api/pandas.Period.dayofweek +generated/pandas.Period.dayofweek,../reference/api/pandas.Period.day_of_week +generated/pandas.Period.day_of_week,../reference/api/pandas.Period.day_of_week generated/pandas.Period.dayofyear,../reference/api/pandas.Period.dayofyear generated/pandas.Period.days_in_month,../reference/api/pandas.Period.days_in_month generated/pandas.Period.daysinmonth,../reference/api/pandas.Period.daysinmonth @@ -1015,7 +1017,8 @@ generated/pandas.Period.hour,../reference/api/pandas.Period.hour generated/pandas.Period,../reference/api/pandas.Period generated/pandas.PeriodIndex.asfreq,../reference/api/pandas.PeriodIndex.asfreq generated/pandas.PeriodIndex.day,../reference/api/pandas.PeriodIndex.day -generated/pandas.PeriodIndex.dayofweek,../reference/api/pandas.PeriodIndex.dayofweek +generated/pandas.PeriodIndex.dayofweek,../reference/api/pandas.PeriodIndex.day_of_week +generated/pandas.PeriodIndex.day_of_week,../reference/api/pandas.PeriodIndex.day_of_week generated/pandas.PeriodIndex.dayofyear,../reference/api/pandas.PeriodIndex.dayofyear generated/pandas.PeriodIndex.days_in_month,../reference/api/pandas.PeriodIndex.days_in_month generated/pandas.PeriodIndex.daysinmonth,../reference/api/pandas.PeriodIndex.daysinmonth @@ -1161,7 +1164,8 @@ generated/pandas.Series.dt.components,../reference/api/pandas.Series.dt.componen generated/pandas.Series.dt.date,../reference/api/pandas.Series.dt.date generated/pandas.Series.dt.day,../reference/api/pandas.Series.dt.day generated/pandas.Series.dt.day_name,../reference/api/pandas.Series.dt.day_name -generated/pandas.Series.dt.dayofweek,../reference/api/pandas.Series.dt.dayofweek +generated/pandas.Series.dt.dayofweek,../reference/api/pandas.Series.dt.day_of_week +generated/pandas.Series.dt.day_of_week,../reference/api/pandas.Series.dt.day_of_week generated/pandas.Series.dt.dayofyear,../reference/api/pandas.Series.dt.dayofyear generated/pandas.Series.dt.days,../reference/api/pandas.Series.dt.days generated/pandas.Series.dt.days_in_month,../reference/api/pandas.Series.dt.days_in_month @@ -1506,7 +1510,8 @@ generated/pandas.Timestamp.ctime,../reference/api/pandas.Timestamp.ctime generated/pandas.Timestamp.date,../reference/api/pandas.Timestamp.date generated/pandas.Timestamp.day,../reference/api/pandas.Timestamp.day generated/pandas.Timestamp.day_name,../reference/api/pandas.Timestamp.day_name -generated/pandas.Timestamp.dayofweek,../reference/api/pandas.Timestamp.dayofweek +generated/pandas.Timestamp.dayofweek,../reference/api/pandas.Timestamp.day_of_week +generated/pandas.Timestamp.day_of_week,../reference/api/pandas.Timestamp.day_of_week generated/pandas.Timestamp.dayofyear,../reference/api/pandas.Timestamp.dayofyear generated/pandas.Timestamp.days_in_month,../reference/api/pandas.Timestamp.days_in_month generated/pandas.Timestamp.daysinmonth,../reference/api/pandas.Timestamp.daysinmonth From a336b2b5d0546455e7ed97147d88a4b199648184 Mon Sep 17 00:00:00 2001 From: hxw Date: Sun, 14 Apr 2019 18:22:40 -0400 Subject: [PATCH 06/10] modified doc/source/reference/arrays.rst --- doc/source/reference/arrays.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/reference/arrays.rst b/doc/source/reference/arrays.rst index 4cf8db895f0ac..0c307db5b12a1 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -60,6 +60,7 @@ Properties Timestamp.asm8 Timestamp.day Timestamp.dayofweek + Timestamp.day_of_week Timestamp.dayofyear Timestamp.days_in_month Timestamp.daysinmonth @@ -223,6 +224,7 @@ Properties Period.day Period.dayofweek + Period.day_of_week Period.dayofyear Period.days_in_month Period.daysinmonth From b9e40b69950c13ae0ab6577da20deb3535bc7a4c Mon Sep 17 00:00:00 2001 From: hxw Date: Sun, 14 Apr 2019 18:32:36 -0400 Subject: [PATCH 07/10] modified doc/source/user_guide/timeseries.rst doc/source/whatsnew/v0.16.2.rst --- doc/source/user_guide/timeseries.rst | 2 +- doc/source/whatsnew/v0.16.2.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/user_guide/timeseries.rst b/doc/source/user_guide/timeseries.rst index 590fde2aaccf8..29da10d0f9712 100644 --- a/doc/source/user_guide/timeseries.rst +++ b/doc/source/user_guide/timeseries.rst @@ -811,7 +811,7 @@ There are several time/date properties that one can access from ``Timestamp`` or dayofyear,"The ordinal day of year" weekofyear,"The week ordinal of the year" week,"The week ordinal of the year" - dayofweek,"The number of the day of the week with Monday=0, Sunday=6" + day_of_week,"The number of the day of the week with Monday=0, Sunday=6" weekday,"The number of the day of the week with Monday=0, Sunday=6" weekday_name,"The name of the day in a week (ex: Friday)" quarter,"Quarter of the date: Jan-Mar = 1, Apr-Jun = 2, etc." diff --git a/doc/source/whatsnew/v0.16.2.rst b/doc/source/whatsnew/v0.16.2.rst index ca0ad8d3ae7f9..f6c4b0ea8755e 100644 --- a/doc/source/whatsnew/v0.16.2.rst +++ b/doc/source/whatsnew/v0.16.2.rst @@ -138,7 +138,7 @@ Bug Fixes - Bug where ``Panel.from_dict`` does not set dtype when specified (:issue:`10058`) - Bug in ``Index.union`` raises ``AttributeError`` when passing array-likes. (:issue:`10149`) - Bug in ``Timestamp``'s' ``microsecond``, ``quarter``, ``dayofyear``, ``week`` and ``daysinmonth`` properties return ``np.int`` type, not built-in ``int``. (:issue:`10050`) -- Bug in ``NaT`` raises ``AttributeError`` when accessing to ``daysinmonth``, ``dayofweek`` properties. (:issue:`10096`) +- Bug in ``NaT`` raises ``AttributeError`` when accessing to ``daysinmonth``, ``dayofweek``, ``day_of_week`` properties. (:issue:`10096`) - Bug in Index repr when using the ``max_seq_items=None`` setting (:issue:`10182`). - Bug in getting timezone data with ``dateutil`` on various platforms ( :issue:`9059`, :issue:`8639`, :issue:`9663`, :issue:`10121`) - Bug in displaying datetimes with mixed frequencies; display 'ms' datetimes to the proper precision. (:issue:`10170`) From ede24efdc5137624a85c27456f872bd54eceb89a Mon Sep 17 00:00:00 2001 From: hxw Date: Sun, 14 Apr 2019 21:41:26 -0400 Subject: [PATCH 08/10] modified datetimes.py period.py in core/arrays core/indexes --- pandas/core/arrays/datetimes.py | 11 ++++++----- pandas/core/arrays/period.py | 7 ++++--- pandas/core/indexes/datetimes.py | 1 + pandas/core/indexes/period.py | 1 + 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index a1857f7bd3f6b..5af0c56f2a2ba 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -247,7 +247,7 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin, 'is_year_end', 'is_leap_year'] _object_ops = ['weekday_name', 'freq', 'tz'] _field_ops = ['year', 'month', 'day', 'hour', 'minute', 'second', - 'weekofyear', 'week', 'weekday', 'dayofweek', + 'weekofyear', 'week', 'weekday', 'dayofweek','day_of_week', 'dayofyear', 'quarter', 'days_in_month', 'daysinmonth', 'microsecond', 'nanosecond'] @@ -1338,14 +1338,14 @@ def date(self): See Also -------- - Series.dt.dayofweek : Alias. + Series.dt.day_of_week : Alias. Series.dt.weekday : Alias. Series.dt.day_name : Returns the name of the day of the week. Examples -------- >>> s = pd.date_range('2016-12-31', '2017-01-08', freq='D').to_series() - >>> s.dt.dayofweek + >>> s.dt.day_of_week 2016-12-31 5 2017-01-01 6 2017-01-02 0 @@ -1357,8 +1357,9 @@ def date(self): 2017-01-08 6 Freq: D, dtype: int64 """ - dayofweek = _field_accessor('dayofweek', 'dow', _dayofweek_doc) - weekday = dayofweek + day_of_week = _field_accessor('day_of_week', 'dow', _dayofweek_doc) + day_of_week = dayofweek + weekday = day_of_week weekday_name = _field_accessor( 'weekday_name', diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index 70312f2e61445..2dce2ce8c2242 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -140,7 +140,7 @@ class PeriodArray(dtl.DatetimeLikeArrayMixin, dtl.DatelikeOps): _bool_ops = ['is_leap_year'] _object_ops = ['start_time', 'end_time', 'freq'] _field_ops = ['year', 'month', 'day', 'hour', 'minute', 'second', - 'weekofyear', 'weekday', 'week', 'dayofweek', + 'weekofyear', 'weekday', 'week', 'dayofweek', 'day_of_week', 'dayofyear', 'quarter', 'qyear', 'days_in_month', 'daysinmonth'] _datetimelike_ops = _field_ops + _object_ops + _bool_ops @@ -299,9 +299,10 @@ def __array__(self, dtype=None): second = _field_accessor('second', 7, "The second of the period") weekofyear = _field_accessor('week', 8, "The week ordinal of the year") week = weekofyear - dayofweek = _field_accessor('dayofweek', 10, + day_of_week = _field_accessor('day_of_week', 10, "The day of the week with Monday=0, Sunday=6") - weekday = dayofweek + day_of_week = dayofweek + weekday = day_of_week dayofyear = day_of_year = _field_accessor('dayofyear', 9, "The ordinal day of the year") quarter = _field_accessor('quarter', 2, "The quarter of the date") diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index ff6d80dbadded..88ae4e34d4bc0 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -173,6 +173,7 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin): weekofyear week dayofweek + day_of_week weekday quarter tz diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 133cf1c0755cf..75e04fd41e7cb 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -120,6 +120,7 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): ---------- day dayofweek + day_of_week dayofyear days_in_month daysinmonth From 51a9a486a1ef52e50247071ca14d0363575777d0 Mon Sep 17 00:00:00 2001 From: hxw Date: Sun, 14 Apr 2019 22:57:51 -0400 Subject: [PATCH 09/10] updated nattype.pyx, period.pyx, timestamps.pyx in pandas/_libs/tslibs --- pandas/_libs/tslibs/nattype.pyx | 2 +- pandas/_libs/tslibs/period.pyx | 53 +++++++++++++++++++++++++++++- pandas/_libs/tslibs/timestamps.pyx | 3 +- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 99f0d77e9bd34..04da28e264400 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -318,6 +318,7 @@ class NaTType(_NaT): weekofyear = property(fget=lambda self: np.nan) days_in_month = property(fget=lambda self: np.nan) daysinmonth = property(fget=lambda self: np.nan) + day_of_week = property(fget=lambda self: np.nan) dayofweek = property(fget=lambda self: np.nan) weekday_name = property(fget=lambda self: np.nan) @@ -386,7 +387,6 @@ class NaTType(_NaT): # ---------------------------------------------------------------------- # The remaining methods have docstrings copy/pasted from the analogous # Timestamp methods. - strptime = _make_error_func('strptime', # noqa:E128 """ Timestamp.strptime(string, format) diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index e5b50ae3c19de..f75ff8595b506 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1957,6 +1957,57 @@ cdef class _Period(object): """ return self.weekofyear + @property + def day_of_week(self): + """ + Day of the week the period lies in, with Monday=0 and Sunday=6. + + If the period frequency is lower than daily (e.g. hourly), and the + period spans over multiple days, the day at the start of the period is + used. + + If the frequency is higher than daily (e.g. monthly), the last day + of the period is used. + + Returns + ------- + int + Day of the week. + + See Also + -------- + Period.day_of_week : Day of the week the period lies in. + Period.weekday : Alias of Period.day_of_week. + Period.day : Day of the month. + Period.dayofyear : Day of the year. + + Examples + -------- + >>> per = pd.Period('2017-12-31 22:00', 'H') + >>> per.day_of_week + 6 + + For periods that span over multiple days, the day at the beginning of + the period is returned. + + >>> per = pd.Period('2017-12-31 22:00', '4H') + >>> per.day_of_week + 6 + >>> per.start_time.day_of_week + 6 + + For periods with a frequency higher than days, the last day of the + period is returned. + + >>> per = pd.Period('2018-01', 'M') + >>> per.day_of_week + 2 + >>> per.end_time.day_of_week + 2 + """ + base, mult = get_freq_code(self.freq) + return pweekday(self.ordinal, base) + @property def dayofweek(self): """ @@ -1976,7 +2027,7 @@ cdef class _Period(object): See Also -------- - Period.dayofweek : Day of the week the period lies in. + Period.day_of_week : Day of the week the period lies in. Period.weekday : Alias of Period.dayofweek. Period.day : Day of the month. Period.dayofyear : Day of the year. diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index c666178b11512..3a116905a42d5 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -595,11 +595,12 @@ class Timestamp(_Timestamp): return Period(self, freq=freq) @property - def dayofweek(self): + def day_of_week(self): """ Return day of whe week. """ return self.weekday() + dayofweek = day_of_week def day_name(self, locale=None): """ From e8bf846edb7be90f2dbaa1da7a806b1f9d6e0f82 Mon Sep 17 00:00:00 2001 From: hxw Date: Sun, 14 Apr 2019 23:16:39 -0400 Subject: [PATCH 10/10] fix indent --- asv_bench/benchmarks/period.py | 2 +- pandas/core/arrays/datetimes.py | 4 ++-- pandas/core/arrays/period.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/asv_bench/benchmarks/period.py b/asv_bench/benchmarks/period.py index cc466b3b0baa7..b3ae36dc97332 100644 --- a/asv_bench/benchmarks/period.py +++ b/asv_bench/benchmarks/period.py @@ -8,7 +8,7 @@ class PeriodProperties(object): params = (['M', 'min'], ['year', 'month', 'day', 'hour', 'minute', 'second', 'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth', - 'day_of_week','dayofyear', 'start_time', 'end_time']) + 'day_of_week', 'dayofyear', 'start_time', 'end_time']) param_names = ['freq', 'attr'] def setup(self, freq, attr): diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 5af0c56f2a2ba..5924618834635 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -247,7 +247,7 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin, 'is_year_end', 'is_leap_year'] _object_ops = ['weekday_name', 'freq', 'tz'] _field_ops = ['year', 'month', 'day', 'hour', 'minute', 'second', - 'weekofyear', 'week', 'weekday', 'dayofweek','day_of_week', + 'weekofyear', 'week', 'weekday', 'dayofweek', 'day_of_week', 'dayofyear', 'quarter', 'days_in_month', 'daysinmonth', 'microsecond', 'nanosecond'] @@ -1358,7 +1358,7 @@ def date(self): Freq: D, dtype: int64 """ day_of_week = _field_accessor('day_of_week', 'dow', _dayofweek_doc) - day_of_week = dayofweek + dayofweek = day_of_week weekday = day_of_week weekday_name = _field_accessor( diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index 2dce2ce8c2242..d9803f81ea18f 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -299,9 +299,9 @@ def __array__(self, dtype=None): second = _field_accessor('second', 7, "The second of the period") weekofyear = _field_accessor('week', 8, "The week ordinal of the year") week = weekofyear - day_of_week = _field_accessor('day_of_week', 10, - "The day of the week with Monday=0, Sunday=6") - day_of_week = dayofweek + day_of_week = _field_accessor( + 'day_of_week', 10, "The day of the week with Monday=0, Sunday=6") + dayofweek = day_of_week weekday = day_of_week dayofyear = day_of_year = _field_accessor('dayofyear', 9, "The ordinal day of the year")