Skip to content

Commit 6794685

Browse files
day_of_year
1 parent 3e652ac commit 6794685

File tree

18 files changed

+39
-38
lines changed

18 files changed

+39
-38
lines changed

asv_bench/benchmarks/period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class PeriodProperties(object):
88
params = (['M', 'min'],
99
['year', 'month', 'day', 'hour', 'minute', 'second',
1010
'is_leap_year', 'quarter', 'qyear', 'week', 'daysinmonth',
11-
'dayofweek', 'dayofyear', 'start_time', 'end_time'])
11+
'dayofweek', 'day_of_year', 'start_time', 'end_time'])
1212
param_names = ['freq', 'attr']
1313

1414
def setup(self, freq, attr):

asv_bench/benchmarks/timestamp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def time_weekday_name(self, tz, freq):
5050
self.ts.day_name
5151

5252
def time_dayofyear(self, tz, freq):
53-
self.ts.dayofyear
53+
self.ts.day_of_year
5454

5555
def time_week(self, tz, freq):
5656
self.ts.week

doc/source/reference/indexing.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ Time/Date Components
350350
DatetimeIndex.time
351351
DatetimeIndex.timetz
352352
DatetimeIndex.dayofyear
353+
DatetimeIndex.day_of_year
353354
DatetimeIndex.weekofyear
354355
DatetimeIndex.week
355356
DatetimeIndex.dayofweek
@@ -452,7 +453,7 @@ Properties
452453

453454
PeriodIndex.day
454455
PeriodIndex.dayofweek
455-
PeriodIndex.dayofyear
456+
PeriodIndex.day_of_year
456457
PeriodIndex.days_in_month
457458
PeriodIndex.daysinmonth
458459
PeriodIndex.end_time

doc/source/reference/series.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ Datetime Properties
327327
Series.dt.weekofyear
328328
Series.dt.dayofweek
329329
Series.dt.weekday
330-
Series.dt.dayofyear
330+
Series.dt.day_of_year
331331
Series.dt.quarter
332332
Series.dt.is_month_start
333333
Series.dt.is_month_end

doc/source/user_guide/timeseries.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ There are several time/date properties that one can access from ``Timestamp`` or
808808
date,"Returns datetime.date (does not contain timezone information)"
809809
time,"Returns datetime.time (does not contain timezone information)"
810810
timetz,"Returns datetime.time as local time with timezone information"
811-
dayofyear,"The ordinal day of year"
811+
day_of_year,"The ordinal day of year"
812812
weekofyear,"The week ordinal of the year"
813813
week,"The week ordinal of the year"
814814
dayofweek,"The number of the day of the week with Monday=0, Sunday=6"

pandas/_libs/tslibs/nattype.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class NaTType(_NaT):
314314
nanosecond = property(fget=lambda self: np.nan)
315315

316316
week = property(fget=lambda self: np.nan)
317-
dayofyear = property(fget=lambda self: np.nan)
317+
day_of_year = property(fget=lambda self: np.nan)
318318
weekofyear = property(fget=lambda self: np.nan)
319319
days_in_month = property(fget=lambda self: np.nan)
320320
daysinmonth = property(fget=lambda self: np.nan)

pandas/_libs/tslibs/period.pyx

+10-10
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ cdef class _Period(object):
17481748
See Also
17491749
--------
17501750
Period.end_time : Return the end Timestamp.
1751-
Period.dayofyear : Return the day of year.
1751+
Period.day_of_year : Return the day of year.
17521752
Period.daysinmonth : Return the days in that month.
17531753
Period.dayofweek : Return the day of the week.
17541754
@@ -1832,7 +1832,7 @@ cdef class _Period(object):
18321832
See Also
18331833
--------
18341834
Period.dayofweek : Get the day of the week.
1835-
Period.dayofyear : Get the day of the year.
1835+
Period.day_of_year : Get the day of the year.
18361836
18371837
Examples
18381838
--------
@@ -1978,7 +1978,7 @@ cdef class _Period(object):
19781978
Period.dayofweek : Day of the week the period lies in.
19791979
Period.weekday : Alias of Period.dayofweek.
19801980
Period.day : Day of the month.
1981-
Period.dayofyear : Day of the year.
1981+
Period.day_of_year : Day of the year.
19821982
19831983
Examples
19841984
--------
@@ -2029,7 +2029,7 @@ cdef class _Period(object):
20292029
Period.dayofweek : Day of the week the period lies in.
20302030
Period.weekday : Alias of Period.dayofweek.
20312031
Period.day : Day of the month.
2032-
Period.dayofyear : Day of the year.
2032+
Period.day_of_year : Day of the year.
20332033
20342034
Examples
20352035
--------
@@ -2061,7 +2061,7 @@ cdef class _Period(object):
20612061
return self.dayofweek
20622062

20632063
@property
2064-
def dayofyear(self):
2064+
def day_of_year(self):
20652065
"""
20662066
Return the day of the year.
20672067
@@ -2078,18 +2078,18 @@ cdef class _Period(object):
20782078
--------
20792079
Period.day : Return the day of the month.
20802080
Period.dayofweek : Return the day of week.
2081-
PeriodIndex.dayofyear : Return the day of year of all indexes.
2081+
PeriodIndex.day_of_year : Return the day of year of all indexes.
20822082
20832083
Examples
20842084
--------
20852085
>>> period = pd.Period("2015-10-23", freq='H')
2086-
>>> period.dayofyear
2086+
>>> period.day_of_year
20872087
296
20882088
>>> period = pd.Period("2012-12-31", freq='D')
2089-
>>> period.dayofyear
2089+
>>> period.day_of_year
20902090
366
20912091
>>> period = pd.Period("2013-01-01", freq='D')
2092-
>>> period.dayofyear
2092+
>>> period.day_of_year
20932093
1
20942094
"""
20952095
base, mult = get_freq_code(self.freq)
@@ -2190,7 +2190,7 @@ cdef class _Period(object):
21902190
See Also
21912191
--------
21922192
Period.days_in_month : Return the days of the month.
2193-
Period.dayofyear : Return the day of the year.
2193+
Period.day_of_year : Return the day of the year.
21942194
21952195
Examples
21962196
--------

pandas/_libs/tslibs/timestamps.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ class Timestamp(_Timestamp):
10221022
return self.day_name()
10231023

10241024
@property
1025-
def dayofyear(self):
1025+
def day_of_year(self):
10261026
"""
10271027
Return the day of the year.
10281028
"""

pandas/core/arrays/datetimes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin,
250250
_object_ops = ['weekday_name', 'freq', 'tz']
251251
_field_ops = ['year', 'month', 'day', 'hour', 'minute', 'second',
252252
'weekofyear', 'week', 'weekday', 'dayofweek',
253-
'dayofyear', 'quarter', 'days_in_month',
253+
'day_of_year', 'quarter', 'days_in_month',
254254
'daysinmonth', 'microsecond',
255255
'nanosecond']
256256
_other_ops = ['date', 'time', 'timetz']
@@ -1368,7 +1368,7 @@ def date(self):
13681368
'weekday_name',
13691369
"The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0")
13701370

1371-
dayofyear = _field_accessor('dayofyear', 'doy',
1371+
day_of_year = _field_accessor('day_of_year', 'doy',
13721372
"The ordinal day of the year.")
13731373
quarter = _field_accessor('quarter', 'q', "The quarter of the date.")
13741374
days_in_month = _field_accessor(

pandas/core/arrays/period.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class PeriodArray(dtl.DatetimeLikeArrayMixin, dtl.DatelikeOps):
137137
_object_ops = ['start_time', 'end_time', 'freq']
138138
_field_ops = ['year', 'month', 'day', 'hour', 'minute', 'second',
139139
'weekofyear', 'weekday', 'week', 'dayofweek',
140-
'dayofyear', 'quarter', 'qyear',
140+
'day_of_year', 'quarter', 'qyear',
141141
'days_in_month', 'daysinmonth']
142142
_datetimelike_ops = _field_ops + _object_ops + _bool_ops
143143
_datetimelike_methods = ['strftime', 'to_timestamp', 'asfreq']
@@ -296,7 +296,7 @@ def __array__(self, dtype=None):
296296
dayofweek = _field_accessor('dayofweek', 10,
297297
"The day of the week with Monday=0, Sunday=6")
298298
weekday = dayofweek
299-
dayofyear = day_of_year = _field_accessor('dayofyear', 9,
299+
day_of_year = _field_accessor('day_of_year', 9,
300300
"The ordinal day of the year")
301301
quarter = _field_accessor('quarter', 2, "The quarter of the date")
302302
qyear = _field_accessor('qyear', 1)

pandas/core/indexes/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin):
172172
date
173173
time
174174
timetz
175-
dayofyear
175+
day_of_year
176176
weekofyear
177177
week
178178
dayofweek

pandas/core/indexes/period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin):
121121
----------
122122
day
123123
dayofweek
124-
dayofyear
124+
day_of_year
125125
days_in_month
126126
daysinmonth
127127
end_time

pandas/tests/indexes/datetimes/test_misc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def test_datetimeindex_accessors(self):
107107
assert dti.microsecond[0] == 0
108108
assert dti.dayofweek[0] == 3
109109

110-
assert dti.dayofyear[0] == 1
111-
assert dti.dayofyear[120] == 121
110+
assert dti.day_of_year[0] == 1
111+
assert dti.day_of_year[120] == 121
112112

113113
assert dti.weekofyear[0] == 1
114114
assert dti.weekofyear[120] == 18
@@ -145,7 +145,7 @@ def test_datetimeindex_accessors(self):
145145
assert len(dti.second) == 365
146146
assert len(dti.microsecond) == 365
147147
assert len(dti.dayofweek) == 365
148-
assert len(dti.dayofyear) == 365
148+
assert len(dti.day_of_year) == 365
149149
assert len(dti.weekofyear) == 365
150150
assert len(dti.quarter) == 365
151151
assert len(dti.is_month_start) == 365

pandas/tests/indexes/datetimes/test_scalar_compat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_dti_date_out_of_range(self, data):
3939
DatetimeIndex(data)
4040

4141
@pytest.mark.parametrize('field', [
42-
'dayofweek', 'dayofyear', 'week', 'weekofyear', 'quarter',
42+
'dayofweek', 'day_of_year', 'week', 'weekofyear', 'quarter',
4343
'days_in_month', 'is_month_start', 'is_month_end',
4444
'is_quarter_start', 'is_quarter_end', 'is_year_start',
4545
'is_year_end', 'weekday_name'])

pandas/tests/indexes/period/test_period.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def test_period_index_length(self):
249249

250250
def test_fields(self):
251251
# year, month, day, hour, minute
252-
# second, weekofyear, week, dayofweek, weekday, dayofyear, quarter
252+
# second, weekofyear, week, dayofweek, weekday, day_of_year, quarter
253253
# qyear
254254
pi = period_range(freq='A', start='1/1/2001', end='12/1/2005')
255255
self._check_all_fields(pi)
@@ -282,7 +282,7 @@ def test_fields(self):
282282

283283
def _check_all_fields(self, periodindex):
284284
fields = ['year', 'month', 'day', 'hour', 'minute', 'second',
285-
'weekofyear', 'week', 'dayofweek', 'dayofyear',
285+
'weekofyear', 'week', 'dayofweek', 'day_of_year',
286286
'quarter', 'qyear', 'days_in_month']
287287

288288
periods = list(periodindex)

pandas/tests/reshape/test_pivot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1034,10 +1034,10 @@ def test_daily(self):
10341034
ts = Series(np.random.randn(len(rng)), index=rng)
10351035

10361036
annual = pivot_table(DataFrame(ts), index=ts.index.year,
1037-
columns=ts.index.dayofyear)
1037+
columns=ts.index.day_of_year)
10381038
annual.columns = annual.columns.droplevel(0)
10391039

1040-
doy = np.asarray(ts.index.dayofyear)
1040+
doy = np.asarray(ts.index.day_of_year)
10411041

10421042
for i in range(1, 367):
10431043
subset = ts[doy == i]

pandas/tests/scalar/period/test_period.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ def test_properties_daily(self):
855855
assert b_date.month == 1
856856
assert b_date.day == 1
857857
assert b_date.weekday == 0
858-
assert b_date.dayofyear == 1
858+
assert b_date.day_of_year == 1
859859
assert b_date.days_in_month == 31
860860
assert Period(freq='B', year=2012,
861861
month=2, day=1).days_in_month == 29
@@ -867,7 +867,7 @@ def test_properties_daily(self):
867867
assert d_date.month == 1
868868
assert d_date.day == 1
869869
assert d_date.weekday == 0
870-
assert d_date.dayofyear == 1
870+
assert d_date.day_of_year == 1
871871
assert d_date.days_in_month == 31
872872
assert Period(freq='D', year=2012, month=2,
873873
day=1).days_in_month == 29
@@ -883,7 +883,7 @@ def test_properties_hourly(self):
883883
assert h_date.month == 1
884884
assert h_date.day == 1
885885
assert h_date.weekday == 0
886-
assert h_date.dayofyear == 1
886+
assert h_date.day_of_year == 1
887887
assert h_date.hour == 0
888888
assert h_date.days_in_month == 31
889889
assert Period(freq='H', year=2012, month=2, day=1,
@@ -898,7 +898,7 @@ def test_properties_minutely(self):
898898
assert t_date.month == 1
899899
assert t_date.day == 1
900900
assert t_date.weekday == 0
901-
assert t_date.dayofyear == 1
901+
assert t_date.day_of_year == 1
902902
assert t_date.hour == 0
903903
assert t_date.minute == 0
904904
assert t_date.days_in_month == 31
@@ -915,7 +915,7 @@ def test_properties_secondly(self):
915915
assert s_date.month == 1
916916
assert s_date.day == 1
917917
assert s_date.weekday == 0
918-
assert s_date.dayofyear == 1
918+
assert s_date.day_of_year == 1
919919
assert s_date.hour == 0
920920
assert s_date.minute == 0
921921
assert s_date.second == 0

pandas/tests/scalar/timestamp/test_timestamp.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def check(value, equal):
6767
check(ts.nanosecond, 1)
6868
check(ts.dayofweek, 6)
6969
check(ts.quarter, 2)
70-
check(ts.dayofyear, 130)
70+
check(ts.day_of_year, 130)
7171
check(ts.week, 19)
7272
check(ts.daysinmonth, 31)
7373
check(ts.daysinmonth, 31)
@@ -87,7 +87,7 @@ def check(value, equal):
8787
check(ts.nanosecond, 0)
8888
check(ts.dayofweek, 2)
8989
check(ts.quarter, 4)
90-
check(ts.dayofyear, 365)
90+
check(ts.day_of_year, 365)
9191
check(ts.week, 1)
9292
check(ts.daysinmonth, 31)
9393

0 commit comments

Comments
 (0)