Skip to content

Commit dc77628

Browse files
committed
Merge remote-tracking branch 'upstream/main' into ref/index_equiv
2 parents 218a0ea + 069f9a4 commit dc77628

File tree

5 files changed

+17
-37
lines changed

5 files changed

+17
-37
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ Removal of prior version deprecations/changes
202202
- Enforced deprecation of :meth:`.DataFrameGroupBy.get_group` and :meth:`.SeriesGroupBy.get_group` allowing the ``name`` argument to be a non-tuple when grouping by a list of length 1 (:issue:`54155`)
203203
- Enforced deprecation of :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` for object-dtype (:issue:`57820`)
204204
- Enforced deprecation of ``axis=None`` acting the same as ``axis=0`` in the DataFrame reductions ``sum``, ``prod``, ``std``, ``var``, and ``sem``, passing ``axis=None`` will now reduce over both axes; this is particularly the case when doing e.g. ``numpy.sum(df)`` (:issue:`21597`)
205+
- Enforced deprecation of parsing system timezone strings to ``tzlocal``, which depended on system timezone, pass the 'tz' keyword instead (:issue:`50791`)
205206
- Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`)
206207
- Enforced deprecation of string ``AS`` denoting frequency in :class:`YearBegin` and strings ``AS-DEC``, ``AS-JAN``, etc. denoting annual frequencies with various fiscal year starts (:issue:`57793`)
207208
- Enforced deprecation of string ``A`` denoting frequency in :class:`YearEnd` and strings ``A-DEC``, ``A-JAN``, etc. denoting annual frequencies with various fiscal year ends (:issue:`57699`)
@@ -211,6 +212,7 @@ Removal of prior version deprecations/changes
211212
- Enforced deprecation of strings ``T``, ``L``, ``U``, and ``N`` denoting units in :class:`Timedelta` (:issue:`57627`)
212213
- Enforced deprecation of the behavior of :func:`concat` when ``len(keys) != len(objs)`` would truncate to the shorter of the two. Now this raises a ``ValueError`` (:issue:`43485`)
213214
- Enforced deprecation of values "pad", "ffill", "bfill", and "backfill" for :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` (:issue:`57869`)
215+
- Enforced deprecation removing :meth:`Categorical.to_list`, use ``obj.tolist()`` instead (:issue:`51254`)
214216
- Enforced silent-downcasting deprecation for :ref:`all relevant methods <whatsnew_220.silent_downcasting>` (:issue:`54710`)
215217
- In :meth:`DataFrame.stack`, the default value of ``future_stack`` is now ``True``; specifying ``False`` will raise a ``FutureWarning`` (:issue:`55448`)
216218
- Iterating over a :class:`.DataFrameGroupBy` or :class:`.SeriesGroupBy` will return tuples of length 1 for the groups when grouping by ``level`` a list of length 1 (:issue:`50064`)

pandas/_libs/tslibs/parsing.pyx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ from decimal import InvalidOperation
4545

4646
from dateutil.parser import DEFAULTPARSER
4747
from dateutil.tz import (
48-
tzlocal as _dateutil_tzlocal,
4948
tzoffset,
5049
tzutc as _dateutil_tzutc,
5150
)
@@ -703,17 +702,12 @@ cdef datetime dateutil_parse(
703702
if res.tzname and res.tzname in time.tzname:
704703
# GH#50791
705704
if res.tzname != "UTC":
706-
# If the system is localized in UTC (as many CI runs are)
707-
# we get tzlocal, once the deprecation is enforced will get
708-
# timezone.utc, not raise.
709-
warnings.warn(
705+
raise ValueError(
710706
f"Parsing '{res.tzname}' as tzlocal (dependent on system timezone) "
711-
"is deprecated and will raise in a future version. Pass the 'tz' "
707+
"is no longer supported. Pass the 'tz' "
712708
"keyword or call tz_localize after construction instead",
713-
FutureWarning,
714-
stacklevel=find_stack_level()
715709
)
716-
ret = ret.replace(tzinfo=_dateutil_tzlocal())
710+
ret = ret.replace(tzinfo=timezone.utc)
717711
elif res.tzoffset == 0:
718712
ret = ret.replace(tzinfo=_dateutil_tzutc())
719713
elif res.tzoffset:

pandas/core/arrays/categorical.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -626,19 +626,6 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike:
626626

627627
return result
628628

629-
def to_list(self) -> list:
630-
"""
631-
Alias for tolist.
632-
"""
633-
# GH#51254
634-
warnings.warn(
635-
"Categorical.to_list is deprecated and will be removed in a future "
636-
"version. Use obj.tolist() instead",
637-
FutureWarning,
638-
stacklevel=find_stack_level(),
639-
)
640-
return self.tolist()
641-
642629
@classmethod
643630
def _from_inferred_categories(
644631
cls, inferred_categories, inferred_codes, dtype, true_values=None

pandas/tests/arrays/categorical/test_api.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818

1919

2020
class TestCategoricalAPI:
21-
def test_to_list_deprecated(self):
22-
# GH#51254
23-
cat1 = Categorical(list("acb"), ordered=False)
24-
msg = "Categorical.to_list is deprecated and will be removed"
25-
with tm.assert_produces_warning(FutureWarning, match=msg):
26-
cat1.to_list()
27-
2821
def test_ordered_api(self):
2922
# GH 9347
3023
cat1 = Categorical(list("acb"), ordered=False)

pandas/tests/tslibs/test_parsing.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import re
77

88
from dateutil.parser import parse as du_parse
9-
from dateutil.tz import tzlocal
109
from hypothesis import given
1110
import numpy as np
1211
import pytest
@@ -22,6 +21,10 @@
2221
)
2322
import pandas.util._test_decorators as td
2423

24+
# Usually we wouldn't want this import in this test file (which is targeted at
25+
# tslibs.parsing), but it is convenient to test the Timestamp constructor at
26+
# the same time as the other parsing functions.
27+
from pandas import Timestamp
2528
import pandas._testing as tm
2629
from pandas._testing._hypothesis import DATETIME_NO_TZ
2730

@@ -33,20 +36,21 @@
3336
def test_parsing_tzlocal_deprecated():
3437
# GH#50791
3538
msg = (
36-
"Parsing 'EST' as tzlocal.*"
39+
r"Parsing 'EST' as tzlocal \(dependent on system timezone\) "
40+
r"is no longer supported\. "
3741
"Pass the 'tz' keyword or call tz_localize after construction instead"
3842
)
3943
dtstr = "Jan 15 2004 03:00 EST"
4044

4145
with tm.set_timezone("US/Eastern"):
42-
with tm.assert_produces_warning(FutureWarning, match=msg):
43-
res, _ = parse_datetime_string_with_reso(dtstr)
46+
with pytest.raises(ValueError, match=msg):
47+
parse_datetime_string_with_reso(dtstr)
4448

45-
assert isinstance(res.tzinfo, tzlocal)
49+
with pytest.raises(ValueError, match=msg):
50+
parsing.py_parse_datetime_string(dtstr)
4651

47-
with tm.assert_produces_warning(FutureWarning, match=msg):
48-
res = parsing.py_parse_datetime_string(dtstr)
49-
assert isinstance(res.tzinfo, tzlocal)
52+
with pytest.raises(ValueError, match=msg):
53+
Timestamp(dtstr)
5054

5155

5256
def test_parse_datetime_string_with_reso():

0 commit comments

Comments
 (0)