8000 DEPR: Remove weekday_name by mroeschke · Pull Request #29831 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DEPR: Remove weekday_name #29831

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

Merged
merged 5 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
DEPR: Remove weekday_name
  • Loading branch information
Matt Roeschke committed Nov 25, 2019
commit 414d6450d0fc86fd2db6707419aed63a570f6071
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
- :func:`read_stata` and :meth:`DataFrame.to_stata` no longer supports the "encoding" argument (:issue:`21400`)
- Removed previously deprecated "raise_conflict" argument from :meth:`DataFrame.update`, use "errors" instead (:issue:`23585`)
- Removed previously deprecated keyword "n" from :meth:`DatetimeIndex.shift`, :meth:`TimedeltaIndex.shift`, :meth:`PeriodIndex.shift`, use "periods" instead (:issue:`22458`)
-
- 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
10000
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):
"""
.. 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
0