Skip to content

Commit c69a611

Browse files
Merge remote-tracking branch 'upstream/master' into arrow-string-array-dtype
2 parents 9e23c35 + 433860b commit c69a611

38 files changed

+583
-190
lines changed

doc/source/ecosystem.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ Statsmodels leverages pandas objects as the underlying data container for comput
7575
Use pandas DataFrames in your `scikit-learn <https://scikit-learn.org/>`__
7676
ML pipeline.
7777

78-
`Featuretools <https://github.com/featuretools/featuretools/>`__
78+
`Featuretools <https://github.com/alteryx/featuretools/>`__
7979
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8080

8181
Featuretools is a Python library for automated feature engineering built on top of pandas. It excels at transforming temporal and relational datasets into feature matrices for machine learning using reusable feature engineering "primitives". Users can contribute their own primitives in Python and share them with the rest of the community.
8282

83-
`Compose <https://github.com/FeatureLabs/compose>`__
83+
`Compose <https://github.com/alteryx/compose>`__
8484
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8585

8686
Compose is a machine learning tool for labeling data and prediction engineering. It allows you to structure the labeling process by parameterizing prediction problems and transforming time-driven relational data into target values with cutoff times that can be used for supervised learning.
@@ -551,11 +551,12 @@ Library Accessor Classes Description
551551
================== ============ ==================================== ===============================================================================
552552
`cyberpandas`_ ``ip`` ``Series`` Provides common operations for working with IP addresses.
553553
`pdvega`_ ``vgplot`` ``Series``, ``DataFrame`` Provides plotting functions from the Altair_ library.
554-
`pandas-genomics`_ ``genomics`` ``Series``, ``DataFrame`` Provides common operations for quality control and analysis of genomics data
554+
`pandas-genomics`_ ``genomics`` ``Series``, ``DataFrame`` Provides common operations for quality control and analysis of genomics data.
555555
`pandas_path`_ ``path`` ``Index``, ``Series`` Provides `pathlib.Path`_ functions for Series.
556556
`pint-pandas`_ ``pint`` ``Series``, ``DataFrame`` Provides units support for numeric Series and DataFrames.
557557
`composeml`_ ``slice`` ``DataFrame`` Provides a generator for enhanced data slicing.
558558
`datatest`_ ``validate`` ``Series``, ``DataFrame``, ``Index`` Provides validation, differences, and acceptance managers.
559+
`woodwork`_ ``ww`` ``Series``, ``DataFrame`` Provides physical, logical, and semantic data typing information for Series and DataFrames.
559560
================== ============ ==================================== ===============================================================================
560561

561562
.. _cyberpandas: https://cyberpandas.readthedocs.io/en/latest
@@ -565,5 +566,6 @@ Library Accessor Classes Description
565566
.. _pandas_path: https://github.com/drivendataorg/pandas-path/
566567
.. _pathlib.Path: https://docs.python.org/3/library/pathlib.html
567568
.. _pint-pandas: https://github.com/hgrecco/pint-pandas
568-
.. _composeml: https://github.com/FeatureLabs/compose
569+
.. _composeml: https://github.com/alteryx/compose
569570
.. _datatest: https://datatest.readthedocs.io/
571+
.. _woodwork: https://github.com/alteryx/woodwork

doc/source/user_guide/style.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@
14621462
"metadata": {},
14631463
"outputs": [],
14641464
"source": [
1465-
"df4.style.format(escape=True)"
1465+
"df4.style.format(escape=\"html\")"
14661466
]
14671467
},
14681468
{
@@ -1471,7 +1471,7 @@
14711471
"metadata": {},
14721472
"outputs": [],
14731473
"source": [
1474-
"df4.style.format('<a href=\"https://pandas.pydata.org\" target=\"_blank\">{}</a>', escape=True)"
1474+
"df4.style.format('<a href=\"https://pandas.pydata.org\" target=\"_blank\">{}</a>', escape=\"html\")"
14751475
]
14761476
},
14771477
{

doc/source/whatsnew/v1.3.0.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,14 @@ Deprecations
729729
- Deprecated the ``convert_float`` optional argument in :func:`read_excel` and :meth:`ExcelFile.parse` (:issue:`41127`)
730730
- Deprecated behavior of :meth:`DatetimeIndex.union` with mixed timezones; in a future version both will be cast to UTC instead of object dtype (:issue:`39328`)
731731
- Deprecated using ``usecols`` with out of bounds indices for ``read_csv`` with ``engine="c"`` (:issue:`25623`)
732+
- Deprecated passing arguments as positional (except for ``"codes"``) in :meth:`MultiIndex.codes` (:issue:`41485`)
733+
- Deprecated passing arguments as positional in :meth:`Index.set_names` and :meth:`MultiIndex.set_names` (except for ``names``) (:issue:`41485`)
734+
- Deprecated passing arguments (apart from ``cond`` and ``other``) as positional in :meth:`DataFrame.mask` and :meth:`Series.mask` (:issue:`41485`)
732735
- Deprecated passing arguments as positional in :meth:`DataFrame.clip` and :meth:`Series.clip` (other than ``"upper"`` and ``"lower"``) (:issue:`41485`)
733736
- Deprecated special treatment of lists with first element a Categorical in the :class:`DataFrame` constructor; pass as ``pd.DataFrame({col: categorical, ...})`` instead (:issue:`38845`)
734737
- Deprecated passing arguments as positional (except for ``"method"``) in :meth:`DataFrame.interpolate` and :meth:`Series.interpolate` (:issue:`41485`)
738+
- Deprecated passing arguments as positional in :meth:`DataFrame.ffill`, :meth:`Series.ffill`, :meth:`DataFrame.bfill`, and :meth:`Series.bfill` (:issue:`41485`)
739+
- Deprecated passing arguments as positional in :meth:`DataFrame.sort_values` (other than ``"by"``) and :meth:`Series.sort_values` (:issue:`41485`)
735740
- Deprecated passing arguments as positional in :meth:`DataFrame.dropna` and :meth:`Series.dropna` (:issue:`41485`)
736741
- Deprecated passing arguments as positional in :meth:`DataFrame.set_index` (other than ``"keys"``) (:issue:`41485`)
737742
- Deprecated passing arguments as positional (except for ``"levels"``) in :meth:`MultiIndex.set_levels` (:issue:`41485`)
@@ -740,7 +745,11 @@ Deprecations
740745
- Deprecated passing arguments (apart from ``value``) as positional in :meth:`DataFrame.fillna` and :meth:`Series.fillna` (:issue:`41485`)
741746
- Deprecated passing arguments as positional in :meth:`DataFrame.reset_index` (other than ``"level"``) and :meth:`Series.reset_index` (:issue:`41485`)
742747
- Deprecated construction of :class:`Series` or :class:`DataFrame` with ``DatetimeTZDtype`` data and ``datetime64[ns]`` dtype. Use ``Series(data).dt.tz_localize(None)`` instead (:issue:`41555`,:issue:`33401`)
748+
- Deprecated passing arguments as positional in :meth:`DataFrame.set_axis` and :meth:`Series.set_axis` (other than ``"labels"``) (:issue:`41485`)
743749
- Deprecated passing arguments as positional in :meth:`DataFrame.where` and :meth:`Series.where` (other than ``"cond"`` and ``"other"``) (:issue:`41485`)
750+
- Deprecated passing arguments as positional in :meth:`DataFrame.drop` (other than ``"labels"``) and :meth:`Series.drop` (:issue:`41485`)
751+
-
752+
744753

745754
.. _whatsnew_130.deprecations.nuisance_columns:
746755

pandas/core/arrays/categorical.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,9 @@ def replace(self, to_replace, value, inplace: bool = False):
24532453

24542454
# ------------------------------------------------------------------------
24552455
# String methods interface
2456-
def _str_map(self, f, na_value=np.nan, dtype=np.dtype("object")):
2456+
def _str_map(
2457+
self, f, na_value=np.nan, dtype=np.dtype("object"), convert: bool = True
2458+
):
24572459
# Optimization to apply the callable `f` to the categories once
24582460
# and rebuild the result by `take`ing from the result with the codes.
24592461
# Returns the same type as the object-dtype implementation though.

pandas/core/arrays/string_.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,9 @@ def _cmp_method(self, other, op):
495495
# String methods interface
496496
_str_na_value = StringDtype.na_value
497497

498-
def _str_map(self, f, na_value=None, dtype: Dtype | None = None):
498+
def _str_map(
499+
self, f, na_value=None, dtype: Dtype | None = None, convert: bool = True
500+
):
499501
from pandas.arrays import BooleanArray
500502

501503
if dtype is None:

pandas/core/arrays/string_arrow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,9 @@ def value_counts(self, dropna: bool = True) -> Series:
653653

654654
_str_na_value = StringDtype.na_value
655655

656-
def _str_map(self, f, na_value=None, dtype: Dtype | None = None):
656+
def _str_map(
657+
self, f, na_value=None, dtype: Dtype | None = None, convert: bool = True
658+
):
657659
# TODO: de-duplicate with StringArray method. This method is moreless copy and
658660
# paste.
659661

pandas/core/frame.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4703,6 +4703,7 @@ def set_axis(
47034703
) -> DataFrame | None:
47044704
...
47054705

4706+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "labels"])
47064707
@Appender(
47074708
"""
47084709
Examples
@@ -4766,6 +4767,7 @@ def reindex(self, *args, **kwargs) -> DataFrame:
47664767
kwargs.pop("labels", None)
47674768
return super().reindex(**kwargs)
47684769

4770+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "labels"])
47694771
def drop(
47704772
self,
47714773
labels=None,
@@ -6221,6 +6223,7 @@ def f(vals) -> tuple[np.ndarray, int]:
62216223
# ----------------------------------------------------------------------
62226224
# Sorting
62236225
# TODO: Just move the sort_values doc here.
6226+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "by"])
62246227
@Substitution(**_shared_doc_kwargs)
62256228
@Appender(NDFrame.sort_values.__doc__)
62266229
# error: Signature of "sort_values" incompatible with supertype "NDFrame"
@@ -10645,6 +10648,26 @@ def values(self) -> np.ndarray:
1064510648
self._consolidate_inplace()
1064610649
return self._mgr.as_array(transpose=True)
1064710650

10651+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self"])
10652+
def ffill(
10653+
self: DataFrame,
10654+
axis: None | Axis = None,
10655+
inplace: bool = False,
10656+
limit: None | int = None,
10657+
downcast=None,
10658+
) -> DataFrame | None:
10659+
return super().ffill(axis, inplace, limit, downcast)
10660+
10661+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self"])
10662+
def bfill(
10663+
self: DataFrame,
10664+
axis: None | Axis = None,
10665+
inplace: bool = False,
10666+
limit: None | int = None,
10667+
downcast=None,
10668+
) -> DataFrame | None:
10669+
return super().bfill(axis, inplace, limit, downcast)
10670+
1064810671
@deprecate_nonkeyword_arguments(
1064910672
version=None, allowed_args=["self", "lower", "upper"]
1065010673
)
@@ -10697,6 +10720,21 @@ def where(
1069710720
):
1069810721
return super().where(cond, other, inplace, axis, level, errors, try_cast)
1069910722

10723+
@deprecate_nonkeyword_arguments(
10724+
version=None, allowed_args=["self", "cond", "other"]
10725+
)
10726+
def mask(
10727+
self,
10728+
cond,
10729+
other=np.nan,
10730+
inplace=False,
10731+
axis=None,
10732+
level=None,
10733+
errors="raise",
10734+
try_cast=lib.no_default,
10735+
):
10736+
return super().mask(cond, other, inplace, axis, level, errors, try_cast)
10737+
1070010738

1070110739
DataFrame._add_numeric_operations()
1070210740

pandas/core/generic.py

Lines changed: 2 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -6392,47 +6392,6 @@ def fillna(
63926392
else:
63936393
return result.__finalize__(self, method="fillna")
63946394

6395-
@overload
6396-
def ffill(
6397-
self: FrameOrSeries,
6398-
axis: None | Axis = ...,
6399-
inplace: Literal[False] = ...,
6400-
limit: None | int = ...,
6401-
downcast=...,
6402-
) -> FrameOrSeries:
6403-
...
6404-
6405-
@overload
6406-
def ffill(
6407-
self: FrameOrSeries,
6408-
axis: None | Axis,
6409-
inplace: Literal[True],
6410-
limit: None | int = ...,
6411-
downcast=...,
6412-
) -> None:
6413-
...
6414-
6415-
@overload
6416-
def ffill(
6417-
self: FrameOrSeries,
6418-
*,
6419-
inplace: Literal[True],
6420-
limit: None | int = ...,
6421-
downcast=...,
6422-
) -> None:
6423-
...
6424-
6425-
@overload
6426-
def ffill(
6427-
self: FrameOrSeries,
6428-
axis: None | Axis = ...,
6429-
inplace: bool_t = ...,
6430-
limit: None | int = ...,
6431-
downcast=...,
6432-
) -> FrameOrSeries | None:
6433-
...
6434-
6435-
@final
64366395
@doc(klass=_shared_doc_kwargs["klass"])
64376396
def ffill(
64386397
self: FrameOrSeries,
@@ -6455,47 +6414,6 @@ def ffill(
64556414

64566415
pad = ffill
64576416

6458-
@overload
6459-
def bfill(
6460-
self: FrameOrSeries,
6461-
axis: None | Axis = ...,
6462-
inplace: Literal[False] = ...,
6463-
limit: None | int = ...,
6464-
downcast=...,
6465-
) -> FrameOrSeries:
6466-
...
6467-
6468-
@overload
6469-
def bfill(
6470-
self: FrameOrSeries,
6471-
axis: None | Axis,
6472-
inplace: Literal[True],
6473-
limit: None | int = ...,
6474-
downcast=...,
6475-
) -> None:
6476-
...
6477-
6478-
@overload
6479-
def bfill(
6480-
self: FrameOrSeries,
6481-
*,
6482-
inplace: Literal[True],
6483-
limit: None | int = ...,
6484-
downcast=...,
6485-
) -> None:
6486-
...
6487-
6488-
@overload
6489-
def bfill(
6490-
self: FrameOrSeries,
6491-
axis: None | Axis = ...,
6492-
inplace: bool_t = ...,
6493-
limit: None | int = ...,
6494-
downcast=...,
6495-
) -> FrameOrSeries | None:
6496-
...
6497-
6498-
@final
64996417
@doc(klass=_shared_doc_kwargs["klass"])
65006418
def bfill(
65016419
self: FrameOrSeries,
@@ -9144,7 +9062,7 @@ def mask(
91449062
"try_cast keyword is deprecated and will be removed in a "
91459063
"future version",
91469064
FutureWarning,
9147-
stacklevel=2,
9065+
stacklevel=4,
91489066
)
91499067

91509068
# see gh-21891
@@ -9303,7 +9221,7 @@ def shift(
93039221
else:
93049222
new_ax = index.shift(periods, freq)
93059223

9306-
result = self.set_axis(new_ax, axis)
9224+
result = self.set_axis(new_ax, axis=axis)
93079225
return result.__finalize__(self, method="shift")
93089226

93099227
@final

pandas/core/indexes/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ def _set_names(self, values, level=None) -> None:
15381538

15391539
names = property(fset=_set_names, fget=_get_names)
15401540

1541-
@final
1541+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "names"])
15421542
def set_names(self, names, level=None, inplace: bool = False):
15431543
"""
15441544
Set Index or MultiIndex name.

pandas/core/indexes/multi.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ class MultiIndex(Index):
292292
_levels = FrozenList()
293293
_codes = FrozenList()
294294
_comparables = ["names"]
295-
rename = Index.set_names
296295

297296
sortorder: int | None
298297

@@ -992,6 +991,7 @@ def _set_codes(
992991

993992
self._reset_cache()
994993

994+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "codes"])
995995
def set_codes(self, codes, level=None, inplace=None, verify_integrity: bool = True):
996996
"""
997997
Set new codes on MultiIndex. Defaults to returning new index.
@@ -1059,7 +1059,7 @@ def set_codes(self, codes, level=None, inplace=None, verify_integrity: bool = Tr
10591059
warnings.warn(
10601060
"inplace is deprecated and will be removed in a future version.",
10611061
FutureWarning,
1062-
stacklevel=2,
1062+
stacklevel=3,
10631063
)
10641064
else:
10651065
inplace = False
@@ -3585,7 +3585,9 @@ def _get_reconciled_name_object(self, other) -> MultiIndex:
35853585
"""
35863586
names = self._maybe_match_names(other)
35873587
if self.names != names:
3588-
return self.rename(names)
3588+
# Incompatible return value type (got "Optional[MultiIndex]", expected
3589+
# "MultiIndex")
3590+
return self.rename(names) # type: ignore[return-value]
35893591
return self
35903592

35913593
def _maybe_match_names(self, other):
@@ -3784,6 +3786,12 @@ def isin(self, values, level=None) -> np.ndarray:
37843786
return np.zeros(len(levs), dtype=np.bool_)
37853787
return levs.isin(values)
37863788

3789+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "names"])
3790+
def set_names(self, names, level=None, inplace: bool = False) -> MultiIndex | None:
3791+
return super().set_names(names=names, level=level, inplace=inplace)
3792+
3793+
rename = set_names
3794+
37873795
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self"])
37883796
def drop_duplicates(self, keep: str | bool = "first") -> MultiIndex:
37893797
return super().drop_duplicates(keep=keep)

0 commit comments

Comments
 (0)