Skip to content

Commit 953e885

Browse files
authored
Merge branch 'pandas-dev:main' into issue-48949
2 parents 4036bfe + cb57af0 commit 953e885

File tree

25 files changed

+88
-604
lines changed

25 files changed

+88
-604
lines changed

.github/workflows/scorecards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
persist-credentials: false
3030

3131
- name: "Run analysis"
32-
uses: ossf/[email protected].3
32+
uses: ossf/[email protected].6
3333
with:
3434
results_file: results.sarif
3535
results_format: sarif

.github/workflows/wheels.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- [windows-2019, win_amd64]
5353
- [windows-2019, win32]
5454
# TODO: support PyPy?
55-
python: [["cp38", "3.8"], ["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11-dev"]]# "pp38", "pp39"]
55+
python: [["cp38", "3.8"], ["cp39", "3.9"], ["cp310", "3.10"], ["cp311", "3.11"]]# "pp38", "pp39"]
5656
env:
5757
IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
5858
IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
@@ -73,7 +73,7 @@ jobs:
7373
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
7474

7575
# Used to test the built wheels
76-
- uses: actions/setup-python@v3
76+
- uses: actions/setup-python@v4
7777
with:
7878
python-version: ${{ matrix.python[1] }}
7979

asv_bench/benchmarks/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ class String:
683683
def setup(self, dtype, method):
684684
cols = list("abcdefghjkl")
685685
self.df = DataFrame(
686-
np.random.randint(0, 100, size=(1_000_000, len(cols))),
686+
np.random.randint(0, 100, size=(10_000, len(cols))),
687687
columns=cols,
688688
dtype=dtype,
689689
)

asv_bench/benchmarks/io/style.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def _style_format(self):
8383
def _style_apply_format_hide(self):
8484
self.st = self.df.style.applymap(lambda v: "color: red;")
8585
self.st.format("{:.3f}")
86-
self.st.hide_index(self.st.index[1:])
87-
self.st.hide_columns(self.st.columns[1:])
86+
self.st.hide(self.st.index[1:], axis=0)
87+
self.st.hide(self.st.columns[1:], axis=1)
8888

8989
def _style_tooltips(self):
9090
ttips = DataFrame("abc", index=self.df.index[::2], columns=self.df.columns[::2])
9191
self.st = self.df.style.set_tooltips(ttips)
92-
self.st.hide_index(self.st.index[12:])
93-
self.st.hide_columns(self.st.columns[12:])
92+
self.st.hide(self.st.index[12:], axis=0)
93+
self.st.hide(self.st.columns[12:], axis=1)

doc/source/getting_started/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Instructions for installing from source,
2020
Python version support
2121
----------------------
2222

23-
Officially Python 3.8, 3.9 and 3.10.
23+
Officially Python 3.8, 3.9, 3.10 and 3.11.
2424

2525
Installing pandas
2626
-----------------

doc/source/whatsnew/v1.5.2.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ including other versions of pandas.
1313

1414
Fixed regressions
1515
~~~~~~~~~~~~~~~~~
16-
-
16+
- Fixed regression in :meth:`Series.replace` raising ``RecursionError`` with numeric dtype and when specifying ``value=None`` (:issue:`45725`)
1717
-
1818

1919
.. ---------------------------------------------------------------------------

doc/source/whatsnew/v2.0.0.rst

+8
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Other API changes
142142
- The ``other`` argument in :meth:`DataFrame.mask` and :meth:`Series.mask` now defaults to ``no_default`` instead of ``np.nan`` consistent with :meth:`DataFrame.where` and :meth:`Series.where`. Entries will be filled with the corresponding NULL value (``np.nan`` for numpy dtypes, ``pd.NA`` for extension dtypes). (:issue:`49111`)
143143
- When creating a :class:`Series` with a object-dtype :class:`Index` of datetime objects, pandas no longer silently converts the index to a :class:`DatetimeIndex` (:issue:`39307`, :issue:`23598`)
144144
- :meth:`Series.unique` with dtype "timedelta64[ns]" or "datetime64[ns]" now returns :class:`TimedeltaArray` or :class:`DatetimeArray` instead of ``numpy.ndarray`` (:issue:`49176`)
145+
- Passing strings that cannot be parsed as datetimes to :class:`Series` or :class:`DataFrame` with ``dtype="datetime64[ns]"`` will raise instead of silently ignoring the keyword and returning ``object`` dtype (:issue:`24435`)
145146
-
146147

147148
.. ---------------------------------------------------------------------------
@@ -157,6 +158,7 @@ Deprecations
157158

158159
Removal of prior version deprecations/changes
159160
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161+
- Removed deprecated module ``pandas.core.index`` (:issue:`30193`)
160162
- Removed deprecated :meth:`Categorical.to_dense`, use ``np.asarray(cat)`` instead (:issue:`32639`)
161163
- Removed deprecated :meth:`Categorical.take_nd` (:issue:`27745`)
162164
- Removed deprecated :meth:`Categorical.mode`, use ``Series(cat).mode()`` instead (:issue:`45033`)
@@ -174,8 +176,14 @@ Removal of prior version deprecations/changes
174176
- Removed deprecated ``weekofyear`` and ``week`` attributes of :class:`DatetimeArray`, :class:`DatetimeIndex` and ``dt`` accessor in favor of ``isocalendar().week`` (:issue:`33595`)
175177
- Removed deprecated :meth:`RangeIndex._start`, :meth:`RangeIndex._stop`, :meth:`RangeIndex._step`, use ``start``, ``stop``, ``step`` instead (:issue:`30482`)
176178
- Removed deprecated :meth:`DatetimeIndex.to_perioddelta`, Use ``dtindex - dtindex.to_period(freq).to_timestamp()`` instead (:issue:`34853`)
179+
- Removed deprecated :meth:`.Styler.hide_index` and :meth:`.Styler.hide_columns` (:issue:`49397`)
180+
- Removed deprecated :meth:`.Styler.set_na_rep` and :meth:`.Styler.set_precision` (:issue:`49397`)
181+
- Removed deprecated :meth:`.Styler.where` (:issue:`49397`)
182+
- Removed deprecated :meth:`.Styler.render` (:issue:`49397`)
183+
- Removed deprecated argument ``null_color`` in :meth:`.Styler.highlight_null` (:issue:`49397`)
177184
- Enforced deprecation disallowing passing a timezone-aware :class:`Timestamp` and ``dtype="datetime64[ns]"`` to :class:`Series` or :class:`DataFrame` constructors (:issue:`41555`)
178185
- Enforced deprecation disallowing passing a sequence of timezone-aware values and ``dtype="datetime64[ns]"`` to to :class:`Series` or :class:`DataFrame` constructors (:issue:`41555`)
186+
- Enforced deprecation disallowing unit-less "datetime64" dtype in :meth:`Series.astype` and :meth:`DataFrame.astype` (:issue:`47844`)
179187
- Enforced deprecation disallowing using ``.astype`` to convert a ``datetime64[ns]`` :class:`Series`, :class:`DataFrame`, or :class:`DatetimeIndex` to timezone-aware dtype, use ``obj.tz_localize`` or ``ser.dt.tz_localize`` instead (:issue:`39258`)
180188
- Enforced deprecation disallowing using ``.astype`` to convert a timezone-aware :class:`Series`, :class:`DataFrame`, or :class:`DatetimeIndex` to timezone-naive ``datetime64[ns]`` dtype, use ``obj.tz_localize(None)`` or ``obj.tz_convert("UTC").tz_localize(None)`` instead (:issue:`39258`)
181189
- Removed Date parser functions :func:`~pandas.io.date_converters.parse_date_time`,

pandas/core/arrays/_mixins.py

-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ def _fill_mask_inplace(
304304
# (for now) when self.ndim == 2, we assume axis=0
305305
func = missing.get_fill_func(method, ndim=self.ndim)
306306
func(self._ndarray.T, limit=limit, mask=mask.T)
307-
return
308307

309308
@doc(ExtensionArray.fillna)
310309
def fillna(

pandas/core/arrays/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,6 @@ def _fill_mask_inplace(
15561556
func(npvalues, limit=limit, mask=mask.copy())
15571557
new_values = self._from_sequence(npvalues, dtype=self.dtype)
15581558
self[mask] = new_values[mask]
1559-
return
15601559

15611560
def _rank(
15621561
self,

pandas/core/arrays/datetimes.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -683,15 +683,10 @@ def astype(self, dtype, copy: bool = True):
683683
and dtype != self.dtype
684684
and is_unitless(dtype)
685685
):
686-
# TODO(2.0): just fall through to dtl.DatetimeLikeArrayMixin.astype
687-
warnings.warn(
688-
"Passing unit-less datetime64 dtype to .astype is deprecated "
689-
"and will raise in a future version. Pass 'datetime64[ns]' instead",
690-
FutureWarning,
691-
stacklevel=find_stack_level(),
686+
raise TypeError(
687+
"Casting to unit-less dtype 'datetime64' is not supported. "
688+
"Pass e.g. 'datetime64[ns]' instead."
692689
)
693-
# unit conversion e.g. datetime64[s]
694-
return self._ndarray.astype(dtype)
695690

696691
elif is_period_dtype(dtype):
697692
return self.to_period(freq=dtype.freq)

pandas/core/dtypes/cast.py

+15-23
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
)
2121
import warnings
2222

23-
from dateutil.parser import ParserError
2423
import numpy as np
2524

2625
from pandas._libs import lib
@@ -1339,28 +1338,21 @@ def maybe_cast_to_datetime(
13391338
if value.size or not is_dtype_equal(value.dtype, dtype):
13401339
_disallow_mismatched_datetimelike(value, dtype)
13411340

1342-
try:
1343-
dta = sequence_to_datetimes(value)
1344-
# GH 25843: Remove tz information since the dtype
1345-
# didn't specify one
1346-
1347-
if dta.tz is not None:
1348-
raise ValueError(
1349-
"Cannot convert timezone-aware data to "
1350-
"timezone-naive dtype. Use "
1351-
"pd.Series(values).dt.tz_localize(None) instead."
1352-
)
1353-
1354-
# TODO(2.0): Do this astype in sequence_to_datetimes to
1355-
# avoid potential extra copy?
1356-
dta = dta.astype(dtype, copy=False)
1357-
value = dta
1358-
1359-
except OutOfBoundsDatetime:
1360-
raise
1361-
except ParserError:
1362-
# Note: this is dateutil's ParserError, not ours.
1363-
pass
1341+
dta = sequence_to_datetimes(value)
1342+
# GH 25843: Remove tz information since the dtype
1343+
# didn't specify one
1344+
1345+
if dta.tz is not None:
1346+
raise ValueError(
1347+
"Cannot convert timezone-aware data to "
1348+
"timezone-naive dtype. Use "
1349+
"pd.Series(values).dt.tz_localize(None) instead."
1350+
)
1351+
1352+
# TODO(2.0): Do this astype in sequence_to_datetimes to
1353+
# avoid potential extra copy?
1354+
dta = dta.astype(dtype, copy=False)
1355+
value = dta
13641356

13651357
elif getattr(vdtype, "kind", None) in ["m", "M"]:
13661358
# we are already datetimelike and want to coerce to non-datetimelike;

pandas/core/index.py

-37
This file was deleted.

pandas/core/internals/blocks.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,6 @@ def replace(
571571
# Note: the checks we do in NDFrame.replace ensure we never get
572572
# here with listlike to_replace or value, as those cases
573573
# go through replace_list
574-
575574
values = self.values
576575

577576
if isinstance(values, Categorical):
@@ -610,7 +609,10 @@ def replace(
610609
return blocks
611610

612611
elif self.ndim == 1 or self.shape[0] == 1:
613-
blk = self.coerce_to_target_dtype(value)
612+
if value is None:
613+
blk = self.astype(np.dtype(object))
614+
else:
615+
blk = self.coerce_to_target_dtype(value)
614616
return blk.replace(
615617
to_replace=to_replace,
616618
value=value,

pandas/core/missing.py

-4
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ def interpolate_array_2d(
258258
fill_value=fill_value,
259259
**kwargs,
260260
)
261-
return
262261

263262

264263
def _interpolate_2d_with_fill(
@@ -341,7 +340,6 @@ def func(yvalues: np.ndarray) -> None:
341340
# Sequence[Sequence[Sequence[_SupportsArray[dtype[<nothing>]]]]],
342341
# Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[<nothing>]]]]]]]]"
343342
np.apply_along_axis(func, axis, data) # type: ignore[arg-type]
344-
return
345343

346344

347345
def _index_to_interp_indices(index: Index, method: str) -> np.ndarray:
@@ -762,8 +760,6 @@ def _interpolate_with_limit_area(
762760

763761
values[invalid] = np.nan
764762

765-
return
766-
767763

768764
def interpolate_2d(
769765
values: np.ndarray,

0 commit comments

Comments
 (0)