From 6794685acac2412f3a600a1b3fafb1f97c306d19 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Fri, 29 Mar 2019 14:14:05 -0400 Subject: [PATCH 01/24] day_of_year --- asv_bench/benchmarks/period.py | 2 +- asv_bench/benchmarks/timestamp.py | 2 +- doc/source/reference/indexing.rst | 3 ++- doc/source/reference/series.rst | 2 +- doc/source/user_guide/timeseries.rst | 2 +- pandas/_libs/tslibs/nattype.pyx | 2 +- pandas/_libs/tslibs/period.pyx | 20 +++++++++---------- pandas/_libs/tslibs/timestamps.pyx | 2 +- pandas/core/arrays/datetimes.py | 4 ++-- pandas/core/arrays/period.py | 4 ++-- pandas/core/indexes/datetimes.py | 2 +- pandas/core/indexes/period.py | 2 +- pandas/tests/indexes/datetimes/test_misc.py | 6 +++--- .../indexes/datetimes/test_scalar_compat.py | 2 +- pandas/tests/indexes/period/test_period.py | 4 ++-- pandas/tests/reshape/test_pivot.py | 4 ++-- pandas/tests/scalar/period/test_period.py | 10 +++++----- .../tests/scalar/timestamp/test_timestamp.py | 4 ++-- 18 files changed, 39 insertions(+), 38 deletions(-) diff --git a/asv_bench/benchmarks/period.py b/asv_bench/benchmarks/period.py index 6d2c7156a0a3d..6ca2188a00d2c 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_year', '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..b8eb7e0c79abb 100644 --- a/asv_bench/benchmarks/timestamp.py +++ b/asv_bench/benchmarks/timestamp.py @@ -50,7 +50,7 @@ def time_weekday_name(self, tz, freq): self.ts.day_name def time_dayofyear(self, tz, freq): - self.ts.dayofyear + self.ts.day_of_year def time_week(self, tz, freq): self.ts.week diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index 680cb7e3dac91..7bd7baa369602 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -350,6 +350,7 @@ Time/Date Components DatetimeIndex.time DatetimeIndex.timetz DatetimeIndex.dayofyear + DatetimeIndex.day_of_year DatetimeIndex.weekofyear DatetimeIndex.week DatetimeIndex.dayofweek @@ -452,7 +453,7 @@ Properties PeriodIndex.day PeriodIndex.dayofweek - PeriodIndex.dayofyear + PeriodIndex.day_of_year PeriodIndex.days_in_month PeriodIndex.daysinmonth PeriodIndex.end_time diff --git a/doc/source/reference/series.rst b/doc/source/reference/series.rst index b406893e3414a..901476ae78601 100644 --- a/doc/source/reference/series.rst +++ b/doc/source/reference/series.rst @@ -327,7 +327,7 @@ Datetime Properties Series.dt.weekofyear Series.dt.dayofweek Series.dt.weekday - Series.dt.dayofyear + Series.dt.day_of_year Series.dt.quarter Series.dt.is_month_start Series.dt.is_month_end diff --git a/doc/source/user_guide/timeseries.rst b/doc/source/user_guide/timeseries.rst index 4e2c428415926..6acba32ebaebc 100644 --- a/doc/source/user_guide/timeseries.rst +++ b/doc/source/user_guide/timeseries.rst @@ -808,7 +808,7 @@ There are several time/date properties that one can access from ``Timestamp`` or date,"Returns datetime.date (does not contain timezone information)" time,"Returns datetime.time (does not contain timezone information)" timetz,"Returns datetime.time as local time with timezone information" - dayofyear,"The ordinal day of year" + day_of_year,"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" diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 79e2e256c501d..37816199b30c9 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -314,7 +314,7 @@ class NaTType(_NaT): nanosecond = property(fget=lambda self: np.nan) week = property(fget=lambda self: np.nan) - dayofyear = property(fget=lambda self: np.nan) + day_of_year = property(fget=lambda self: np.nan) weekofyear = property(fget=lambda self: np.nan) days_in_month = property(fget=lambda self: np.nan) daysinmonth = property(fget=lambda self: np.nan) diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index a5a50ea59753d..1cae94f92bd40 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1748,7 +1748,7 @@ cdef class _Period(object): See Also -------- Period.end_time : Return the end Timestamp. - Period.dayofyear : Return the day of year. + Period.day_of_year : Return the day of year. Period.daysinmonth : Return the days in that month. Period.dayofweek : Return the day of the week. @@ -1832,7 +1832,7 @@ cdef class _Period(object): See Also -------- Period.dayofweek : Get the day of the week. - Period.dayofyear : Get the day of the year. + Period.day_of_year : Get the day of the year. Examples -------- @@ -1978,7 +1978,7 @@ cdef class _Period(object): Period.dayofweek : 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. + Period.day_of_year : Day of the year. Examples -------- @@ -2029,7 +2029,7 @@ cdef class _Period(object): Period.dayofweek : 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. + Period.day_of_year : Day of the year. Examples -------- @@ -2061,7 +2061,7 @@ cdef class _Period(object): return self.dayofweek @property - def dayofyear(self): + def day_of_year(self): """ Return the day of the year. @@ -2078,18 +2078,18 @@ cdef class _Period(object): -------- Period.day : Return the day of the month. Period.dayofweek : Return the day of week. - PeriodIndex.dayofyear : Return the day of year of all indexes. + PeriodIndex.day_of_year : Return the day of year of all indexes. Examples -------- >>> period = pd.Period("2015-10-23", freq='H') - >>> period.dayofyear + >>> period.day_of_year 296 >>> period = pd.Period("2012-12-31", freq='D') - >>> period.dayofyear + >>> period.day_of_year 366 >>> period = pd.Period("2013-01-01", freq='D') - >>> period.dayofyear + >>> period.day_of_year 1 """ base, mult = get_freq_code(self.freq) @@ -2190,7 +2190,7 @@ cdef class _Period(object): See Also -------- Period.days_in_month : Return the days of the month. - Period.dayofyear : Return the day of the year. + Period.day_of_year : Return the day of the year. Examples -------- diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 8d825e0a6179e..e2e9d07019a81 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -1022,7 +1022,7 @@ class Timestamp(_Timestamp): return self.day_name() @property - def dayofyear(self): + def day_of_year(self): """ Return the day of the year. """ diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 75cf658423210..831aa022b89e4 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -250,7 +250,7 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin, _object_ops = ['weekday_name', 'freq', 'tz'] _field_ops = ['year', 'month', 'day', 'hour', 'minute', 'second', 'weekofyear', 'week', 'weekday', 'dayofweek', - 'dayofyear', 'quarter', 'days_in_month', + 'day_of_year', 'quarter', 'days_in_month', 'daysinmonth', 'microsecond', 'nanosecond'] _other_ops = ['date', 'time', 'timetz'] @@ -1368,7 +1368,7 @@ def date(self): 'weekday_name', "The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0") - dayofyear = _field_accessor('dayofyear', 'doy', + day_of_year = _field_accessor('day_of_year', 'doy', "The ordinal day of the year.") quarter = _field_accessor('quarter', 'q', "The quarter of the date.") days_in_month = _field_accessor( diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index 3ddceb8c2839d..ae56cb0b3d0d0 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -137,7 +137,7 @@ class PeriodArray(dtl.DatetimeLikeArrayMixin, dtl.DatelikeOps): _object_ops = ['start_time', 'end_time', 'freq'] _field_ops = ['year', 'month', 'day', 'hour', 'minute', 'second', 'weekofyear', 'weekday', 'week', 'dayofweek', - 'dayofyear', 'quarter', 'qyear', + 'day_of_year', 'quarter', 'qyear', 'days_in_month', 'daysinmonth'] _datetimelike_ops = _field_ops + _object_ops + _bool_ops _datetimelike_methods = ['strftime', 'to_timestamp', 'asfreq'] @@ -296,7 +296,7 @@ def __array__(self, dtype=None): dayofweek = _field_accessor('dayofweek', 10, "The day of the week with Monday=0, Sunday=6") weekday = dayofweek - dayofyear = day_of_year = _field_accessor('dayofyear', 9, + day_of_year = _field_accessor('day_of_year', 9, "The ordinal day of the year") quarter = _field_accessor('quarter', 2, "The quarter of the date") qyear = _field_accessor('qyear', 1) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index b8d052ce7be04..7b04ffb5f0f73 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -172,7 +172,7 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin): date time timetz - dayofyear + day_of_year weekofyear week dayofweek diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index a4bd7f9017eb4..df54714bed5b0 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -121,7 +121,7 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): ---------- day dayofweek - dayofyear + day_of_year days_in_month daysinmonth end_time diff --git a/pandas/tests/indexes/datetimes/test_misc.py b/pandas/tests/indexes/datetimes/test_misc.py index fc6080e68a803..8014e54a1e105 100644 --- a/pandas/tests/indexes/datetimes/test_misc.py +++ b/pandas/tests/indexes/datetimes/test_misc.py @@ -107,8 +107,8 @@ def test_datetimeindex_accessors(self): assert dti.microsecond[0] == 0 assert dti.dayofweek[0] == 3 - assert dti.dayofyear[0] == 1 - assert dti.dayofyear[120] == 121 + assert dti.day_of_year[0] == 1 + assert dti.day_of_year[120] == 121 assert dti.weekofyear[0] == 1 assert dti.weekofyear[120] == 18 @@ -145,7 +145,7 @@ def test_datetimeindex_accessors(self): assert len(dti.second) == 365 assert len(dti.microsecond) == 365 assert len(dti.dayofweek) == 365 - assert len(dti.dayofyear) == 365 + assert len(dti.day_of_year) == 365 assert len(dti.weekofyear) == 365 assert len(dti.quarter) == 365 assert len(dti.is_month_start) == 365 diff --git a/pandas/tests/indexes/datetimes/test_scalar_compat.py b/pandas/tests/indexes/datetimes/test_scalar_compat.py index 42338a751e0fc..3a940ea624c22 100644 --- a/pandas/tests/indexes/datetimes/test_scalar_compat.py +++ b/pandas/tests/indexes/datetimes/test_scalar_compat.py @@ -39,7 +39,7 @@ def test_dti_date_out_of_range(self, data): DatetimeIndex(data) @pytest.mark.parametrize('field', [ - 'dayofweek', 'dayofyear', 'week', 'weekofyear', 'quarter', + 'dayofweek', 'day_of_year', 'week', 'weekofyear', 'quarter', 'days_in_month', 'is_month_start', 'is_month_end', 'is_quarter_start', 'is_quarter_end', 'is_year_start', 'is_year_end', 'weekday_name']) diff --git a/pandas/tests/indexes/period/test_period.py b/pandas/tests/indexes/period/test_period.py index 89bcf56dbda71..fae64f9faa132 100644 --- a/pandas/tests/indexes/period/test_period.py +++ b/pandas/tests/indexes/period/test_period.py @@ -249,7 +249,7 @@ def test_period_index_length(self): def test_fields(self): # year, month, day, hour, minute - # second, weekofyear, week, dayofweek, weekday, dayofyear, quarter + # second, weekofyear, week, dayofweek, weekday, day_of_year, quarter # qyear pi = period_range(freq='A', start='1/1/2001', end='12/1/2005') self._check_all_fields(pi) @@ -282,7 +282,7 @@ def test_fields(self): def _check_all_fields(self, periodindex): fields = ['year', 'month', 'day', 'hour', 'minute', 'second', - 'weekofyear', 'week', 'dayofweek', 'dayofyear', + 'weekofyear', 'week', 'dayofweek', 'day_of_year', 'quarter', 'qyear', 'days_in_month'] periods = list(periodindex) diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index e4fbb204af533..59a211fca6644 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -1034,10 +1034,10 @@ def test_daily(self): ts = Series(np.random.randn(len(rng)), index=rng) annual = pivot_table(DataFrame(ts), index=ts.index.year, - columns=ts.index.dayofyear) + columns=ts.index.day_of_year) annual.columns = annual.columns.droplevel(0) - doy = np.asarray(ts.index.dayofyear) + doy = np.asarray(ts.index.day_of_year) for i in range(1, 367): subset = ts[doy == i] diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index 8ca19745055a3..de851ebd7e762 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -855,7 +855,7 @@ def test_properties_daily(self): assert b_date.month == 1 assert b_date.day == 1 assert b_date.weekday == 0 - assert b_date.dayofyear == 1 + assert b_date.day_of_year == 1 assert b_date.days_in_month == 31 assert Period(freq='B', year=2012, month=2, day=1).days_in_month == 29 @@ -867,7 +867,7 @@ def test_properties_daily(self): assert d_date.month == 1 assert d_date.day == 1 assert d_date.weekday == 0 - assert d_date.dayofyear == 1 + assert d_date.day_of_year == 1 assert d_date.days_in_month == 31 assert Period(freq='D', year=2012, month=2, day=1).days_in_month == 29 @@ -883,7 +883,7 @@ def test_properties_hourly(self): assert h_date.month == 1 assert h_date.day == 1 assert h_date.weekday == 0 - assert h_date.dayofyear == 1 + assert h_date.day_of_year == 1 assert h_date.hour == 0 assert h_date.days_in_month == 31 assert Period(freq='H', year=2012, month=2, day=1, @@ -898,7 +898,7 @@ def test_properties_minutely(self): assert t_date.month == 1 assert t_date.day == 1 assert t_date.weekday == 0 - assert t_date.dayofyear == 1 + assert t_date.day_of_year == 1 assert t_date.hour == 0 assert t_date.minute == 0 assert t_date.days_in_month == 31 @@ -915,7 +915,7 @@ def test_properties_secondly(self): assert s_date.month == 1 assert s_date.day == 1 assert s_date.weekday == 0 - assert s_date.dayofyear == 1 + assert s_date.day_of_year == 1 assert s_date.hour == 0 assert s_date.minute == 0 assert s_date.second == 0 diff --git a/pandas/tests/scalar/timestamp/test_timestamp.py b/pandas/tests/scalar/timestamp/test_timestamp.py index b55d00b44fd67..9fa8d883e34c0 100644 --- a/pandas/tests/scalar/timestamp/test_timestamp.py +++ b/pandas/tests/scalar/timestamp/test_timestamp.py @@ -67,7 +67,7 @@ def check(value, equal): check(ts.nanosecond, 1) check(ts.dayofweek, 6) check(ts.quarter, 2) - check(ts.dayofyear, 130) + check(ts.day_of_year, 130) check(ts.week, 19) check(ts.daysinmonth, 31) check(ts.daysinmonth, 31) @@ -87,7 +87,7 @@ def check(value, equal): check(ts.nanosecond, 0) check(ts.dayofweek, 2) check(ts.quarter, 4) - check(ts.dayofyear, 365) + check(ts.day_of_year, 365) check(ts.week, 1) check(ts.daysinmonth, 31) From f990e59e07086d36884a25bcf380ef85ec457a76 Mon Sep 17 00:00:00 2001 From: Oleksii Polovyi Date: Fri, 29 Mar 2019 14:17:53 -0400 Subject: [PATCH 02/24] Update indexing.rst --- doc/source/reference/indexing.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index 7bd7baa369602..6ad55d09a2198 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -349,7 +349,6 @@ Time/Date Components DatetimeIndex.date DatetimeIndex.time DatetimeIndex.timetz - DatetimeIndex.dayofyear DatetimeIndex.day_of_year DatetimeIndex.weekofyear DatetimeIndex.week From 2a372a98c9a5d7da128bfcb64d452f617fc1ea4d Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Fri, 29 Mar 2019 14:58:01 -0400 Subject: [PATCH 03/24] bug fix --- doc/redirects.csv | 10 +++++----- doc/source/reference/arrays.rst | 4 ++-- doc/source/reference/indexing.rst | 2 +- doc/source/whatsnew/v0.16.2.rst | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/redirects.csv b/doc/redirects.csv index a7886779c97d5..58dcf181c76b8 100644 --- a/doc/redirects.csv +++ b/doc/redirects.csv @@ -528,7 +528,7 @@ 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.dayofyear,../reference/api/pandas.DatetimeIndex.dayofyear +generated/pandas.DatetimeIndex.day_of_year,../reference/api/pandas.DatetimeIndex.day_of_year generated/pandas.DatetimeIndex.floor,../reference/api/pandas.DatetimeIndex.floor generated/pandas.DatetimeIndex.freq,../reference/api/pandas.DatetimeIndex.freq generated/pandas.DatetimeIndex.freqstr,../reference/api/pandas.DatetimeIndex.freqstr @@ -1005,7 +1005,7 @@ 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.dayofyear,../reference/api/pandas.Period.dayofyear +generated/pandas.Period.day_of_year,../reference/api/pandas.Period.day_of_year generated/pandas.Period.days_in_month,../reference/api/pandas.Period.days_in_month generated/pandas.Period.daysinmonth,../reference/api/pandas.Period.daysinmonth generated/pandas.Period.end_time,../reference/api/pandas.Period.end_time @@ -1016,7 +1016,7 @@ 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.dayofyear,../reference/api/pandas.PeriodIndex.dayofyear +generated/pandas.PeriodIndex.day_of_year,../reference/api/pandas.PeriodIndex.day_of_year generated/pandas.PeriodIndex.days_in_month,../reference/api/pandas.PeriodIndex.days_in_month generated/pandas.PeriodIndex.daysinmonth,../reference/api/pandas.PeriodIndex.daysinmonth generated/pandas.PeriodIndex.end_time,../reference/api/pandas.PeriodIndex.end_time @@ -1162,7 +1162,7 @@ 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.dayofyear,../reference/api/pandas.Series.dt.dayofyear +generated/pandas.Series.dt.day_of_year,../reference/api/pandas.Series.dt.day_of_year 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 generated/pandas.Series.dt.daysinmonth,../reference/api/pandas.Series.dt.daysinmonth @@ -1507,7 +1507,7 @@ 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.dayofyear,../reference/api/pandas.Timestamp.dayofyear +generated/pandas.Timestamp.day_of_year,../reference/api/pandas.Timestamp.day_of_year generated/pandas.Timestamp.days_in_month,../reference/api/pandas.Timestamp.days_in_month generated/pandas.Timestamp.daysinmonth,../reference/api/pandas.Timestamp.daysinmonth generated/pandas.Timestamp.dst,../reference/api/pandas.Timestamp.dst diff --git a/doc/source/reference/arrays.rst b/doc/source/reference/arrays.rst index a129b75636536..3d6f768cda951 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -60,7 +60,7 @@ Properties Timestamp.asm8 Timestamp.day Timestamp.dayofweek - Timestamp.dayofyear + Timestamp.day_of_year Timestamp.days_in_month Timestamp.daysinmonth Timestamp.fold @@ -223,7 +223,7 @@ Properties Period.day Period.dayofweek - Period.dayofyear + Period.day_of_year Period.days_in_month Period.daysinmonth Period.end_time diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index 7bd7baa369602..13b778efaf91f 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -349,7 +349,7 @@ Time/Date Components DatetimeIndex.date DatetimeIndex.time DatetimeIndex.timetz - DatetimeIndex.dayofyear + DatetimeIndex.day_of_year DatetimeIndex.day_of_year DatetimeIndex.weekofyear DatetimeIndex.week diff --git a/doc/source/whatsnew/v0.16.2.rst b/doc/source/whatsnew/v0.16.2.rst index ca0ad8d3ae7f9..60cb1b4125d92 100644 --- a/doc/source/whatsnew/v0.16.2.rst +++ b/doc/source/whatsnew/v0.16.2.rst @@ -137,7 +137,7 @@ Bug Fixes - Bug in ``mean()`` where integer dtypes can overflow (:issue:`10172`) - 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 ``Timestamp``'s' ``microsecond``, ``quarter``, ``day_of_year``, ``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 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`) From e89e36d7ed3947d46dbfe15ffed0b72e8bba690d Mon Sep 17 00:00:00 2001 From: Oleksii Polovyi Date: Fri, 29 Mar 2019 15:20:10 -0400 Subject: [PATCH 04/24] Update indexing.rst --- doc/source/reference/indexing.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index ad7ce4e256300..6ad55d09a2198 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -349,10 +349,6 @@ Time/Date Components DatetimeIndex.date DatetimeIndex.time DatetimeIndex.timetz -<<<<<<< HEAD - DatetimeIndex.day_of_year -======= ->>>>>>> f990e59e07086d36884a25bcf380ef85ec457a76 DatetimeIndex.day_of_year DatetimeIndex.weekofyear DatetimeIndex.week From 0b92861f661a09046c763334a3b12f4a76efc69d Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Fri, 29 Mar 2019 15:23:46 -0400 Subject: [PATCH 05/24] fix indent --- pandas/core/arrays/datetimes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 831aa022b89e4..449aefb318e41 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -1369,7 +1369,7 @@ def date(self): "The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0") day_of_year = _field_accessor('day_of_year', 'doy', - "The ordinal day of the year.") + "The ordinal day of the year.") quarter = _field_accessor('quarter', 'q', "The quarter of the date.") days_in_month = _field_accessor( 'days_in_month', From 337227894beed233be9866635826917a2bf351a7 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Fri, 29 Mar 2019 15:26:12 -0400 Subject: [PATCH 06/24] indent fix --- pandas/core/arrays/period.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index ae56cb0b3d0d0..f677cf586595a 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -297,7 +297,7 @@ def __array__(self, dtype=None): "The day of the week with Monday=0, Sunday=6") weekday = dayofweek day_of_year = _field_accessor('day_of_year', 9, - "The ordinal day of the year") + "The ordinal day of the year") quarter = _field_accessor('quarter', 2, "The quarter of the date") qyear = _field_accessor('qyear', 1) days_in_month = _field_accessor('days_in_month', 11, From f5038d072ebe2981f510746b17909c9b93c98758 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sat, 1 Jun 2019 21:50:23 -0400 Subject: [PATCH 07/24] keep dayofyear for deprecation --- 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 96ec35ec0cb5d..8f9f0d2c40869 100644 --- a/asv_bench/benchmarks/period.py +++ b/asv_bench/benchmarks/period.py @@ -8,7 +8,7 @@ class PeriodProperties: params = (['M', 'min'], ['year', 'month', 'day', 'hour', 'minute', 'second', 'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth', - 'dayofweek', 'day_of_year', 'start_time', 'end_time']) + 'dayofweek', 'dayofyear', 'day_of_year', 'start_time', 'end_time']) param_names = ['freq', 'attr'] def setup(self, freq, attr): From f548d01310c7c6831f31c452ea65b99d757fa862 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sat, 1 Jun 2019 21:52:52 -0400 Subject: [PATCH 08/24] add day_of_week to params --- 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 8f9f0d2c40869..ff7c5f2ca00c4 100644 --- a/asv_bench/benchmarks/period.py +++ b/asv_bench/benchmarks/period.py @@ -8,7 +8,7 @@ class PeriodProperties: params = (['M', 'min'], ['year', 'month', 'day', 'hour', 'minute', 'second', 'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth', - 'dayofweek', 'dayofyear', 'day_of_year', 'start_time', 'end_time']) + 'dayofweek', 'day_of_week', 'dayofyear', 'day_of_year', 'start_time', 'end_time']) param_names = ['freq', 'attr'] def setup(self, freq, attr): From adea39b9f8e5459790da45d6f2def27a324c4aa2 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sat, 1 Jun 2019 21:53:31 -0400 Subject: [PATCH 09/24] add days_in_month to params --- 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 ff7c5f2ca00c4..d1aae01b56f39 100644 --- a/asv_bench/benchmarks/period.py +++ b/asv_bench/benchmarks/period.py @@ -7,7 +7,7 @@ class PeriodProperties: params = (['M', 'min'], ['year', 'month', 'day', 'hour', 'minute', 'second', - 'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth', + 'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth', 'days_in_month', 'dayofweek', 'day_of_week', 'dayofyear', 'day_of_year', 'start_time', 'end_time']) param_names = ['freq', 'attr'] From 5ab6273221b363fc99b4bac8d006549585e5851b Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sat, 1 Jun 2019 22:02:17 -0400 Subject: [PATCH 10/24] fix pep8 issue --- asv_bench/benchmarks/period.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/asv_bench/benchmarks/period.py b/asv_bench/benchmarks/period.py index d1aae01b56f39..e38305e7d681d 100644 --- a/asv_bench/benchmarks/period.py +++ b/asv_bench/benchmarks/period.py @@ -7,8 +7,9 @@ class PeriodProperties: params = (['M', 'min'], ['year', 'month', 'day', 'hour', 'minute', 'second', - 'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth', 'days_in_month', - 'dayofweek', 'day_of_week', 'dayofyear', 'day_of_year', 'start_time', 'end_time']) + 'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth', + 'days_in_month', 'dayofweek', 'day_of_week', 'dayofyear', + 'day_of_year', 'start_time', 'end_time']) param_names = ['freq', 'attr'] def setup(self, freq, attr): From d13907ec5b42956714495a1ea22de383004b8c7a Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sat, 1 Jun 2019 22:11:34 -0400 Subject: [PATCH 11/24] fix jreback's suggestion --- doc/source/whatsnew/v0.16.2.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.16.2.rst b/doc/source/whatsnew/v0.16.2.rst index 60cb1b4125d92..ca0ad8d3ae7f9 100644 --- a/doc/source/whatsnew/v0.16.2.rst +++ b/doc/source/whatsnew/v0.16.2.rst @@ -137,7 +137,7 @@ Bug Fixes - Bug in ``mean()`` where integer dtypes can overflow (:issue:`10172`) - 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``, ``day_of_year``, ``week`` and ``daysinmonth`` properties return ``np.int`` type, not built-in ``int``. (:issue:`10050`) +- 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 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`) From 891533577835a1ebe5a4d601f526157480963f3f Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sat, 1 Jun 2019 23:52:50 -0400 Subject: [PATCH 12/24] add deprecation warnings --- asv_bench/benchmarks/timestamp.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/asv_bench/benchmarks/timestamp.py b/asv_bench/benchmarks/timestamp.py index c99d840971ae2..05ec535372cdb 100644 --- a/asv_bench/benchmarks/timestamp.py +++ b/asv_bench/benchmarks/timestamp.py @@ -4,7 +4,7 @@ import pytz from pandas import Timestamp - +from pandas.util._decorators import deprecate class TimestampConstruction: @@ -37,6 +37,9 @@ class TimestampProperties: params = [_tzs, _freqs] param_names = ['tz', 'freq'] + deprecate('time_dayofweek', 'time_day_of_week', '0.21.0') + deprecate('time_dayofyear', 'time_day_of_year', '0.21.0') + def setup(self, tz, freq): self.ts = Timestamp('2017-08-25 08:16:14', tzinfo=tz, freq=freq) @@ -45,11 +48,17 @@ def time_tz(self, tz, freq): def time_dayofweek(self, tz, freq): self.ts.dayofweek + + def time_day_of_week(self, tz, freq): + self.ts.day_of_week def time_weekday_name(self, tz, freq): self.ts.day_name def time_dayofyear(self, tz, freq): + self.ts.dayofyear + + def time_day_of_year(self, tz, freq): self.ts.day_of_year def time_week(self, tz, freq): From 558f804847f85bef649ab59b0f97a571bda1daf3 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sat, 1 Jun 2019 23:56:48 -0400 Subject: [PATCH 13/24] fix version in deprecate(...) --- asv_bench/benchmarks/timestamp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asv_bench/benchmarks/timestamp.py b/asv_bench/benchmarks/timestamp.py index 05ec535372cdb..eb1fbcba84214 100644 --- a/asv_bench/benchmarks/timestamp.py +++ b/asv_bench/benchmarks/timestamp.py @@ -37,8 +37,8 @@ class TimestampProperties: params = [_tzs, _freqs] param_names = ['tz', 'freq'] - deprecate('time_dayofweek', 'time_day_of_week', '0.21.0') - deprecate('time_dayofyear', 'time_day_of_year', '0.21.0') + deprecate('time_dayofweek', 'time_day_of_week', '0.25.0') + deprecate('time_dayofyear', 'time_day_of_year', '0.25.0') def setup(self, tz, freq): self.ts = Timestamp('2017-08-25 08:16:14', tzinfo=tz, freq=freq) From 4035c7340076770bc8dd1da65006f4eb80b7c140 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 12:35:38 -0400 Subject: [PATCH 14/24] fix redirects.csv --- doc/redirects.csv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/redirects.csv b/doc/redirects.csv index 58dcf181c76b8..cc80dbebf0636 100644 --- a/doc/redirects.csv +++ b/doc/redirects.csv @@ -528,6 +528,8 @@ 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.day_of_week,../reference/api/pandas.DatetimeIndex.day_of_week +generated/pandas.DatetimeIndex.dayofyear,../reference/api/pandas.DatetimeIndex.dayofyear generated/pandas.DatetimeIndex.day_of_year,../reference/api/pandas.DatetimeIndex.day_of_year generated/pandas.DatetimeIndex.floor,../reference/api/pandas.DatetimeIndex.floor generated/pandas.DatetimeIndex.freq,../reference/api/pandas.DatetimeIndex.freq From f129f129089422ca67f49f11e855120e078045cc Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 12:40:05 -0400 Subject: [PATCH 15/24] fix redirects.csv --- doc/redirects.csv | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/redirects.csv b/doc/redirects.csv index cc80dbebf0636..cd79f23a01839 100644 --- a/doc/redirects.csv +++ b/doc/redirects.csv @@ -1007,6 +1007,8 @@ 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.day_of_week,../reference/api/pandas.Period.day_of_week +generated/pandas.Period.dayofyear,../reference/api/pandas.Period.dayofyear generated/pandas.Period.day_of_year,../reference/api/pandas.Period.day_of_year generated/pandas.Period.days_in_month,../reference/api/pandas.Period.days_in_month generated/pandas.Period.daysinmonth,../reference/api/pandas.Period.daysinmonth @@ -1018,6 +1020,8 @@ 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.day_of_week,../reference/api/pandas.PeriodIndex.day_of_week +generated/pandas.PeriodIndex.dayofyear,../reference/api/pandas.PeriodIndex.dayofyear generated/pandas.PeriodIndex.day_of_year,../reference/api/pandas.PeriodIndex.day_of_year generated/pandas.PeriodIndex.days_in_month,../reference/api/pandas.PeriodIndex.days_in_month generated/pandas.PeriodIndex.daysinmonth,../reference/api/pandas.PeriodIndex.daysinmonth @@ -1164,6 +1168,8 @@ 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.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.day_of_year,../reference/api/pandas.Series.dt.day_of_year 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 @@ -1509,6 +1515,8 @@ 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.day_of_week,../reference/api/pandas.Timestamp.day_of_week +generated/pandas.Timestamp.dayofyear,../reference/api/pandas.Timestamp.dayofyear generated/pandas.Timestamp.day_of_year,../reference/api/pandas.Timestamp.day_of_year generated/pandas.Timestamp.days_in_month,../reference/api/pandas.Timestamp.days_in_month generated/pandas.Timestamp.daysinmonth,../reference/api/pandas.Timestamp.daysinmonth From 192cfcb7706914c3710fca463999640d03463ddf Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 12:42:22 -0400 Subject: [PATCH 16/24] update dayofyear and dayofweek --- 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 a3a20475b6719..1bb56e5b8bd98 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -60,6 +60,8 @@ Properties Timestamp.asm8 Timestamp.day Timestamp.dayofweek + Timestamp.day_of_week + Timestamp.dayofyear Timestamp.day_of_year Timestamp.days_in_month Timestamp.daysinmonth From cc48825a1570c1814b33e8575e141fa94255f4b2 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 12:43:14 -0400 Subject: [PATCH 17/24] fix dayofweek and dayofyear --- 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 1bb56e5b8bd98..70e4a4c2ad195 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -230,6 +230,8 @@ Properties Period.day Period.dayofweek + Period.day_of_week + Period.dayofyear Period.day_of_year Period.days_in_month Period.daysinmonth From 30a4d910c150c2b427104b6cd071018e6736140d Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 12:44:53 -0400 Subject: [PATCH 18/24] update dayofyear and dayofweek --- doc/source/reference/indexing.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index 09444499aa5d0..a0115c7270491 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -349,10 +349,12 @@ Time/Date Components DatetimeIndex.date DatetimeIndex.time DatetimeIndex.timetz + DatetimeIndex.dayofyear DatetimeIndex.day_of_year DatetimeIndex.weekofyear DatetimeIndex.week DatetimeIndex.dayofweek + DatetimeIndex.day_of_week DatetimeIndex.weekday DatetimeIndex.quarter DatetimeIndex.tz @@ -452,6 +454,8 @@ Properties PeriodIndex.day PeriodIndex.dayofweek + PeriodIndex.day_of_week + PeriodIndex.dayofyear PeriodIndex.day_of_year PeriodIndex.days_in_month PeriodIndex.daysinmonth From 8eed38c95afd8d6fafd201a84b6afa0b14cbb2c6 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 12:45:57 -0400 Subject: [PATCH 19/24] update dayofyear and dayofweek --- doc/source/reference/series.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/reference/series.rst b/doc/source/reference/series.rst index 901476ae78601..636091dcd4b89 100644 --- a/doc/source/reference/series.rst +++ b/doc/source/reference/series.rst @@ -326,7 +326,9 @@ Datetime Properties Series.dt.week Series.dt.weekofyear Series.dt.dayofweek + Series.dt.day_of_week Series.dt.weekday + Series.dt.dayofyear Series.dt.day_of_year Series.dt.quarter Series.dt.is_month_start From da53b42d9d68dab1ba908299135b2acaaf354290 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 12:54:49 -0400 Subject: [PATCH 20/24] update timeseries.rst --- doc/source/user_guide/timeseries.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/user_guide/timeseries.rst b/doc/source/user_guide/timeseries.rst index f31d32c34cfd9..5b8630e202d0f 100644 --- a/doc/source/user_guide/timeseries.rst +++ b/doc/source/user_guide/timeseries.rst @@ -811,10 +811,12 @@ There are several time/date properties that one can access from ``Timestamp`` or date,"Returns datetime.date (does not contain timezone information)" time,"Returns datetime.time (does not contain timezone information)" timetz,"Returns datetime.time as local time with timezone information" + dayofyear,"The ordinal day of year" day_of_year,"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." From 6428c34d5816cb65b2ba0fa6997f721df22606fc Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 12:58:36 -0400 Subject: [PATCH 21/24] update nattype.pyx --- pandas/_libs/tslibs/nattype.pyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index a2318fa06a4cb..1679e6de81a88 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -312,11 +312,13 @@ class NaTType(_NaT): nanosecond = property(fget=lambda self: np.nan) week = property(fget=lambda self: np.nan) + dayofyear = property(fget=lambda self: np.nan) day_of_year = property(fget=lambda self: np.nan) weekofyear = property(fget=lambda self: np.nan) days_in_month = property(fget=lambda self: np.nan) daysinmonth = property(fget=lambda self: np.nan) dayofweek = property(fget=lambda self: np.nan) + day_of_week = property(fget=lambda self: np.nan) weekday_name = property(fget=lambda self: np.nan) # inject Timedelta properties From aa031803be34e75bbb6d1319c099e17fd2437854 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 15:26:51 -0400 Subject: [PATCH 22/24] day_of_week and day_of_year --- pandas/_libs/tslibs/period.pyx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index db22385c9fa25..bd7c23515acd0 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -1748,9 +1748,11 @@ cdef class _Period: See Also -------- Period.end_time : Return the end Timestamp. + Period.dayofyear : Return the day of year. Period.day_of_year : Return the day of year. Period.daysinmonth : Return the days in that month. Period.dayofweek : Return the day of the week. + Period.day_of_week : Return the day of the week. Examples -------- @@ -1832,6 +1834,8 @@ cdef class _Period: See Also -------- Period.dayofweek : Get the day of the week. + Period.day_of_week : Get the day of the week. + Period.dayofyear : Get the day of the year. Period.day_of_year : Get the day of the year. Examples @@ -1976,8 +1980,10 @@ cdef class _Period: 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. Period.day_of_year : Day of the year. Examples @@ -2027,8 +2033,10 @@ cdef class _Period: 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. Period.day_of_year : Day of the year. Examples From e3d3e5c6ca9038faf5b2eda519fe87bc1da19fa2 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 15:41:34 -0400 Subject: [PATCH 23/24] update test_timestamp.py --- pandas/tests/scalar/timestamp/test_timestamp.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/tests/scalar/timestamp/test_timestamp.py b/pandas/tests/scalar/timestamp/test_timestamp.py index 3d12fa1fa331d..ab079d1f2aeb5 100644 --- a/pandas/tests/scalar/timestamp/test_timestamp.py +++ b/pandas/tests/scalar/timestamp/test_timestamp.py @@ -65,7 +65,9 @@ def check(value, equal): check(ts.microsecond, 100) check(ts.nanosecond, 1) check(ts.dayofweek, 6) + check(ts.day_of_week, 6) check(ts.quarter, 2) + check(ts.dayofyear, 130) check(ts.day_of_year, 130) check(ts.week, 19) check(ts.daysinmonth, 31) @@ -85,7 +87,9 @@ def check(value, equal): check(ts.microsecond, 0) check(ts.nanosecond, 0) check(ts.dayofweek, 2) + check(ts.day_of_week, 2) check(ts.quarter, 4) + check(ts.dayofyear, 365) check(ts.day_of_year, 365) check(ts.week, 1) check(ts.daysinmonth, 31) From 67eec73ed71c77ebbe385583c1a84050a06bff59 Mon Sep 17 00:00:00 2001 From: ApolllonDev Date: Sun, 2 Jun 2019 15:44:42 -0400 Subject: [PATCH 24/24] update test_period.py --- pandas/tests/scalar/period/test_period.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index d1acca36de82e..8ad71d815a1cd 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -854,6 +854,7 @@ def test_properties_daily(self): assert b_date.month == 1 assert b_date.day == 1 assert b_date.weekday == 0 + assert b_date.dayofyear == 1 assert b_date.day_of_year == 1 assert b_date.days_in_month == 31 assert Period(freq='B', year=2012, @@ -866,6 +867,7 @@ def test_properties_daily(self): assert d_date.month == 1 assert d_date.day == 1 assert d_date.weekday == 0 + assert d_date.dayofyear == 1 assert d_date.day_of_year == 1 assert d_date.days_in_month == 31 assert Period(freq='D', year=2012, month=2, @@ -882,6 +884,7 @@ def test_properties_hourly(self): assert h_date.month == 1 assert h_date.day == 1 assert h_date.weekday == 0 + assert h_date.dayofyear == 1 assert h_date.day_of_year == 1 assert h_date.hour == 0 assert h_date.days_in_month == 31 @@ -897,6 +900,7 @@ def test_properties_minutely(self): assert t_date.month == 1 assert t_date.day == 1 assert t_date.weekday == 0 + assert t_date.dayofyear == 1 assert t_date.day_of_year == 1 assert t_date.hour == 0 assert t_date.minute == 0 @@ -914,6 +918,7 @@ def test_properties_secondly(self): assert s_date.month == 1 assert s_date.day == 1 assert s_date.weekday == 0 + assert s_date.dayofyear == 1 assert s_date.day_of_year == 1 assert s_date.hour == 0 assert s_date.minute == 0