Skip to content

Commit 3bc720f

Browse files
authored
Merge branch 'main' into autofilter-feature
2 parents dd7a53e + f33207b commit 3bc720f

File tree

8 files changed

+452
-18
lines changed

8 files changed

+452
-18
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ All warnings for upcoming changes in pandas will have the base class :class:`pan
156156

157157
Other enhancements
158158
^^^^^^^^^^^^^^^^^^
159+
- :class:`pandas.NamedAgg` now supports passing ``*args`` and ``**kwargs``
160+
to calls of ``aggfunc`` (:issue:`58283`)
159161
- :func:`pandas.merge` propagates the ``attrs`` attribute to the result if all
160162
inputs have identical ``attrs``, as has so far already been the case for
161163
:func:`pandas.concat`.
@@ -1122,6 +1124,7 @@ I/O
11221124
- Bug in :meth:`read_csv` for the ``c`` and ``python`` engines where parsing numbers with large exponents caused overflows. Now, numbers with large positive exponents are parsed as ``inf`` or ``-inf`` depending on the sign of the mantissa, while those with large negative exponents are parsed as ``0.0`` (:issue:`62617`, :issue:`38794`, :issue:`62740`)
11231125
- Bug in :meth:`read_csv` raising ``TypeError`` when ``index_col`` is specified and ``na_values`` is a dict containing the key ``None``. (:issue:`57547`)
11241126
- Bug in :meth:`read_csv` raising ``TypeError`` when ``nrows`` and ``iterator`` are specified without specifying a ``chunksize``. (:issue:`59079`)
1127+
- Bug in :meth:`read_csv` where it did not appropriately skip a line when instructed, causing Empty Data Error (:issue:`62739`)
11251128
- Bug in :meth:`read_csv` where the order of the ``na_values`` makes an inconsistency when ``na_values`` is a list non-string values. (:issue:`59303`)
11261129
- Bug in :meth:`read_csv` with ``c`` and ``python`` engines reading big integers as strings. Now reads them as python integers. (:issue:`51295`)
11271130
- Bug in :meth:`read_csv` with ``engine="c"`` reading large float numbers with preceding integers as strings. Now reads them as floats. (:issue:`51295`)

pandas/core/apply.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,13 @@ def reconstruct_func(
17451745
>>> reconstruct_func("min")
17461746
(False, 'min', None, None)
17471747
"""
1748-
relabeling = func is None and is_multi_agg_with_relabel(**kwargs)
1748+
from pandas.core.groupby.generic import NamedAgg
1749+
1750+
relabeling = func is None and (
1751+
is_multi_agg_with_relabel(**kwargs)
1752+
or any(isinstance(v, NamedAgg) for v in kwargs.values())
1753+
)
1754+
17491755
columns: tuple[str, ...] | None = None
17501756
order: npt.NDArray[np.intp] | None = None
17511757

@@ -1766,9 +1772,22 @@ def reconstruct_func(
17661772
# "Callable[..., Any] | str | list[Callable[..., Any] | str] |
17671773
# MutableMapping[Hashable, Callable[..., Any] | str | list[Callable[..., Any] |
17681774
# str]] | None")
1775+
converted_kwargs = {}
1776+
for key, val in kwargs.items():
1777+
if isinstance(val, NamedAgg):
1778+
aggfunc = val.aggfunc
1779+
if val.args or val.kwargs:
1780+
aggfunc = lambda x, func=aggfunc, a=val.args, kw=val.kwargs: func(
1781+
x, *a, **kw
1782+
)
1783+
converted_kwargs[key] = (val.column, aggfunc)
1784+
else:
1785+
converted_kwargs[key] = val
1786+
17691787
func, columns, order = normalize_keyword_aggregation( # type: ignore[assignment]
1770-
kwargs
1788+
converted_kwargs
17711789
)
1790+
17721791
assert func is not None
17731792

17741793
return relabeling, func, columns, order

pandas/core/arrays/boolean.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@ class BooleanDtype(BaseMaskedDtype):
4545
"""
4646
Extension dtype for boolean data.
4747
48+
This is a pandas Extension dtype for boolean data with support for
49+
missing values. BooleanDtype is the dtype companion to :class:`.BooleanArray`,
50+
which implements Kleene logic (sometimes called three-value logic) for
51+
logical operations. See :ref:`boolean.kleene` for more.
52+
4853
.. warning::
4954
50-
BooleanDtype is considered experimental. The implementation and
51-
parts of the API may change without warning.
55+
BooleanDtype is considered experimental. The implementation and
56+
parts of the API may change without warning.
5257
5358
Attributes
5459
----------
@@ -60,12 +65,24 @@ class BooleanDtype(BaseMaskedDtype):
6065
6166
See Also
6267
--------
68+
arrays.BooleanArray : Array of boolean (True/False) data with missing values.
69+
Int64Dtype : Extension dtype for int64 integer data.
6370
StringDtype : Extension dtype for string data.
6471
6572
Examples
6673
--------
6774
>>> pd.BooleanDtype()
6875
BooleanDtype
76+
77+
>>> pd.array([True, False, None], dtype=pd.BooleanDtype())
78+
<BooleanArray>
79+
[True, False, <NA>]
80+
Length: 3, dtype: boolean
81+
82+
>>> pd.array([True, False, None], dtype="boolean")
83+
<BooleanArray>
84+
[True, False, <NA>]
85+
Length: 3, dtype: boolean
6986
"""
7087

7188
name: ClassVar[str] = "boolean"

0 commit comments

Comments
 (0)