Skip to content
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

DEPR: Remove weekday_name #29831

Merged
merged 5 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions doc/source/user_guide/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,6 @@ There are several time/date properties that one can access from ``Timestamp`` or
week,"The week ordinal of the year"
dayofweek,"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."
days_in_month,"The number of days in the month of the datetime"
is_month_start,"Logical indicating if first day of month (defined by frequency)"
Expand Down Expand Up @@ -1591,18 +1590,18 @@ labels.

s = pd.date_range('2000-01-01', '2000-01-05').to_series()
s.iloc[2] = pd.NaT
s.dt.weekday_name
s.dt.day_name()

# default: label='left', closed='left'
s.resample('B').last().dt.weekday_name
s.resample('B').last().dt.day_name()

Notice how the value for Sunday got pulled back to the previous Friday.
To get the behavior where the value for Sunday is pushed to Monday, use
instead

.. ipython:: python

s.resample('B', label='right', closed='right').last().dt.weekday_name
s.resample('B', label='right', closed='right').last().dt.day_name()

The ``axis`` parameter can be set to 0 or 1 and allows you to resample the
specified axis for a ``DataFrame``.
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
- Removed previously deprecated keyword "n" from :meth:`DatetimeIndex.shift`, :meth:`TimedeltaIndex.shift`, :meth:`PeriodIndex.shift`, use "periods" instead (:issue:`22458`)
- Changed the default value for the `raw` argument in :func:`Series.rolling().apply() <pandas.core.window.Rolling.apply>`, :func:`DataFrame.rolling().apply() <pandas.core.window.Rolling.apply>`,
- :func:`Series.expanding().apply() <pandas.core.window.Expanding.apply>`, and :func:`DataFrame.expanding().apply() <pandas.core.window.Expanding.apply>` to ``False`` (:issue:`20584`)
- Removed previously deprecated :attr:`Timestamp.weekday_name`, :attr:`DatetimeIndex.weekday_name`, and :attr:`Series.dt.weekday_name` (:issue:`18164`)
-

.. _whatsnew_1000.performance:
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/fields.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def build_field_sarray(const int64_t[:] dtindex):
def get_date_name_field(const int64_t[:] dtindex, object field, object locale=None):
"""
Given a int64-based datetime index, return array of strings of date
name based on requested field (e.g. weekday_name)
name based on requested field (e.g. day_name)
"""
cdef:
Py_ssize_t i, count = len(dtindex)
Expand All @@ -100,7 +100,7 @@ def get_date_name_field(const int64_t[:] dtindex, object field, object locale=No

out = np.empty(count, dtype=object)

if field == 'day_name' or field == 'weekday_name':
if field == 'day_name':
if locale is None:
names = np.array(DAYS_FULL, dtype=np.object_)
else:
Expand Down
1 change: 0 additions & 1 deletion pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ class NaTType(_NaT):
days_in_month = property(fget=lambda self: np.nan)
daysinmonth = property(fget=lambda self: np.nan)
dayofweek = property(fget=lambda self: np.nan)
weekday_name = property(fget=lambda self: np.nan)

# inject Timedelta properties
days = property(fget=lambda self: np.nan)
Expand Down
11 changes: 0 additions & 11 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -638,17 +638,6 @@ timedelta}, default 'raise'
"""
return self._get_date_name_field('month_name', locale)

@property
def weekday_name(self) -> str:
"""
.. deprecated:: 0.23.0
Use ``Timestamp.day_name()`` instead
"""
warnings.warn("`weekday_name` is deprecated and will be removed in a "
"future version. Use `day_name` instead",
FutureWarning)
return self.day_name()

@property
def dayofyear(self):
"""
Expand Down
10 changes: 1 addition & 9 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class DatetimeArray(dtl.DatetimeLikeArrayMixin, dtl.TimelikeOps, dtl.DatelikeOps
"is_year_end",
"is_leap_year",
]
_object_ops = ["weekday_name", "freq", "tz"]
_object_ops = ["freq", "tz"]
_field_ops = [
"year",
"month",
Expand Down Expand Up @@ -1509,14 +1509,6 @@ def date(self):
dayofweek = _field_accessor("dayofweek", "dow", _dayofweek_doc)
weekday = dayofweek

weekday_name = _field_accessor(
"weekday_name",
"weekday_name",
"""
The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0
""",
)

dayofyear = _field_accessor(
"dayofyear",
"doy",
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/indexes/datetimes/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def test_datetimeindex_accessors(self):
assert len(dti.is_quarter_end) == 365
assert len(dti.is_year_start) == 365
assert len(dti.is_year_end) == 365
assert len(dti.weekday_name) == 365

dti.name = "name"

Expand Down Expand Up @@ -339,11 +338,8 @@ def test_datetime_name_accessors(self, time_locale):
]
for day, name, eng_name in zip(range(4, 11), expected_days, english_days):
name = name.capitalize()
assert dti.weekday_name[day] == eng_name
assert dti.day_name(locale=time_locale)[day] == name
ts = Timestamp(datetime(2016, 4, day))
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
assert ts.weekday_name == eng_name
assert ts.day_name(locale=time_locale) == name
dti = dti.append(DatetimeIndex([pd.NaT]))
assert np.isnan(dti.day_name(locale=time_locale)[-1])
Expand Down
7 changes: 1 addition & 6 deletions pandas/tests/indexes/datetimes/test_scalar_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,13 @@ def test_dti_date_out_of_range(self, data):
"is_quarter_end",
"is_year_start",
"is_year_end",
"weekday_name",
],
)
def test_dti_timestamp_fields(self, field):
# extra fields from DatetimeIndex like quarter and week
idx = tm.makeDateIndex(100)
expected = getattr(idx, field)[-1]
if field == "weekday_name":
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
result = getattr(Timestamp(idx[-1]), field)
else:
result = getattr(Timestamp(idx[-1]), field)
result = getattr(Timestamp(idx[-1]), field)
assert result == expected

def test_dti_timestamp_freq_fields(self):
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/scalar/timestamp/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ def check(value, equal):
)
def test_names(self, data, time_locale):
# GH 17354
# Test .weekday_name, .day_name(), .month_name
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
assert data.weekday_name == "Monday"
# Test .day_name(), .month_name
if time_locale is None:
expected_day = "Monday"
expected_month = "August"
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/series/test_datetime_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ def test_dt_accessor_datetime_name_accessors(self, time_locale):
]
for day, name, eng_name in zip(range(4, 11), expected_days, english_days):
name = name.capitalize()
assert s.dt.weekday_name[day] == eng_name
assert s.dt.day_name(locale=time_locale)[day] == name
s = s.append(Series([pd.NaT]))
assert np.isnan(s.dt.day_name(locale=time_locale).iloc[-1])
Expand Down