Skip to content

Commit 4417f0f

Browse files
authored
Merge branch 'main' into lock-block-values-refs
2 parents e21c3c9 + 9501650 commit 4417f0f

File tree

20 files changed

+183
-13
lines changed

20 files changed

+183
-13
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
fi
3535
python -m pip install --no-build-isolation -ve . -Csetup-args="--werror"
3636
PATH=$HOME/miniconda3/envs/pandas-dev/bin:$HOME/miniconda3/condabin:$PATH
37-
sudo apt-get update && sudo apt-get install -y libegl1 libopengl0
3837
ci/run_tests.sh
3938
test-linux-musl:
4039
docker:

ci/code_checks.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8181
-i "pandas.Timestamp.resolution PR02" \
8282
-i "pandas.Timestamp.tzinfo GL08" \
8383
-i "pandas.arrays.ArrowExtensionArray PR07,SA01" \
84-
-i "pandas.arrays.IntervalArray.length SA01" \
8584
-i "pandas.arrays.NumpyExtensionArray SA01" \
8685
-i "pandas.arrays.TimedeltaArray PR07,SA01" \
8786
-i "pandas.core.groupby.DataFrameGroupBy.plot PR02" \

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Other enhancements
5656
- :meth:`DataFrame.plot.scatter` argument ``c`` now accepts a column of strings, where rows with the same string are colored identically (:issue:`16827` and :issue:`16485`)
5757
- :func:`read_parquet` accepts ``to_pandas_kwargs`` which are forwarded to :meth:`pyarrow.Table.to_pandas` which enables passing additional keywords to customize the conversion to pandas, such as ``maps_as_pydicts`` to read the Parquet map data type as python dictionaries (:issue:`56842`)
5858
- :meth:`DataFrameGroupBy.transform`, :meth:`SeriesGroupBy.transform`, :meth:`DataFrameGroupBy.agg`, :meth:`SeriesGroupBy.agg`, :meth:`RollingGroupby.apply`, :meth:`ExpandingGroupby.apply`, :meth:`Rolling.apply`, :meth:`Expanding.apply`, :meth:`DataFrame.apply` with ``engine="numba"`` now supports positional arguments passed as kwargs (:issue:`58995`)
59+
- :meth:`Rolling.agg`, :meth:`Expanding.agg` and :meth:`ExponentialMovingWindow.agg` now accept :class:`NamedAgg` aggregations through ``**kwargs`` (:issue:`28333`)
5960
- :meth:`Series.map` can now accept kwargs to pass on to func (:issue:`59814`)
6061
- :meth:`pandas.concat` will raise a ``ValueError`` when ``ignore_index=True`` and ``keys`` is not ``None`` (:issue:`59274`)
6162
- :meth:`str.get_dummies` now accepts a ``dtype`` parameter to specify the dtype of the resulting DataFrame (:issue:`47872`)

pandas/core/arrays/interval.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,20 @@ def length(self) -> Index:
13061306
"""
13071307
Return an Index with entries denoting the length of each Interval.
13081308
1309+
The length of an interval is calculated as the difference between
1310+
its `right` and `left` bounds. This property is particularly useful
1311+
when working with intervals where the size of the interval is an important
1312+
attribute, such as in time-series analysis or spatial data analysis.
1313+
1314+
See Also
1315+
--------
1316+
arrays.IntervalArray.left : Return the left endpoints of each Interval in
1317+
the IntervalArray as an Index.
1318+
arrays.IntervalArray.right : Return the right endpoints of each Interval in
1319+
the IntervalArray as an Index.
1320+
arrays.IntervalArray.mid : Return the midpoint of each Interval in the
1321+
IntervalArray as an Index.
1322+
13091323
Examples
13101324
--------
13111325

pandas/core/computation/expressions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _evaluate_numexpr(op, op_str, left_op, right_op):
108108
try:
109109
result = ne.evaluate(
110110
f"left_value {op_str} right_value",
111-
local_dict={"left_value": left_value, "right_value": right_op},
111+
local_dict={"left_value": left_value, "right_value": right_value},
112112
casting="safe",
113113
)
114114
except TypeError:
@@ -257,7 +257,10 @@ def where(cond, left_op, right_op, use_numexpr: bool = True):
257257
Whether to try to use numexpr.
258258
"""
259259
assert _where is not None
260-
return _where(cond, left_op, right_op) if use_numexpr else _where_standard(cond, left_op, right_op)
260+
if use_numexpr:
261+
return _where(cond, left_op, right_op)
262+
else:
263+
return _where_standard(cond, left_op, right_op)
261264

262265

263266
def set_test_mode(v: bool = True) -> None:

pandas/core/computation/pytables.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ def stringify(value):
274274
# string quoting
275275
return TermValue(conv_val, stringify(conv_val), "string")
276276
else:
277-
raise TypeError(f"Cannot compare {conv_val} of type {type(conv_val)} to {kind} column")
277+
raise TypeError(
278+
f"Cannot compare {conv_val} of type {type(conv_val)} to {kind} column"
279+
)
278280

279281
def convert_values(self) -> None:
280282
pass

pandas/core/window/ewm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def online(
490490
klass="Series/Dataframe",
491491
axis="",
492492
)
493-
def aggregate(self, func, *args, **kwargs):
493+
def aggregate(self, func=None, *args, **kwargs):
494494
return super().aggregate(func, *args, **kwargs)
495495

496496
agg = aggregate
@@ -981,7 +981,7 @@ def reset(self) -> None:
981981
"""
982982
self._mean.reset()
983983

984-
def aggregate(self, func, *args, **kwargs):
984+
def aggregate(self, func=None, *args, **kwargs):
985985
raise NotImplementedError("aggregate is not implemented.")
986986

987987
def std(self, bias: bool = False, *args, **kwargs):

pandas/core/window/expanding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def _get_window_indexer(self) -> BaseIndexer:
167167
klass="Series/Dataframe",
168168
axis="",
169169
)
170-
def aggregate(self, func, *args, **kwargs):
170+
def aggregate(self, func=None, *args, **kwargs):
171171
return super().aggregate(func, *args, **kwargs)
172172

173173
agg = aggregate

pandas/core/window/rolling.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444

4545
from pandas.core._numba import executor
4646
from pandas.core.algorithms import factorize
47-
from pandas.core.apply import ResamplerWindowApply
47+
from pandas.core.apply import (
48+
ResamplerWindowApply,
49+
reconstruct_func,
50+
)
4851
from pandas.core.arrays import ExtensionArray
4952
from pandas.core.base import SelectionMixin
5053
import pandas.core.common as com
@@ -646,8 +649,12 @@ def _numba_apply(
646649
out = obj._constructor(result, index=index, columns=columns)
647650
return self._resolve_output(out, obj)
648651

649-
def aggregate(self, func, *args, **kwargs):
652+
def aggregate(self, func=None, *args, **kwargs):
653+
relabeling, func, columns, order = reconstruct_func(func, **kwargs)
650654
result = ResamplerWindowApply(self, func, args=args, kwargs=kwargs).agg()
655+
if isinstance(result, ABCDataFrame) and relabeling:
656+
result = result.iloc[:, order]
657+
result.columns = columns # type: ignore[union-attr]
651658
if result is None:
652659
return self.apply(func, raw=False, args=args, kwargs=kwargs)
653660
return result
@@ -1239,7 +1246,7 @@ def calc(x):
12391246
klass="Series/DataFrame",
12401247
axis="",
12411248
)
1242-
def aggregate(self, func, *args, **kwargs):
1249+
def aggregate(self, func=None, *args, **kwargs):
12431250
result = ResamplerWindowApply(self, func, args=args, kwargs=kwargs).agg()
12441251
if result is None:
12451252
# these must apply directly
@@ -1951,7 +1958,7 @@ def _raise_monotonic_error(self, msg: str):
19511958
klass="Series/Dataframe",
19521959
axis="",
19531960
)
1954-
def aggregate(self, func, *args, **kwargs):
1961+
def aggregate(self, func=None, *args, **kwargs):
19551962
return super().aggregate(func, *args, **kwargs)
19561963

19571964
agg = aggregate

pandas/tests/extension/test_arrow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,7 @@ def test_from_arrow_respecting_given_dtype():
16471647

16481648
def test_from_arrow_respecting_given_dtype_unsafe():
16491649
array = pa.array([1.5, 2.5], type=pa.float64())
1650-
with pytest.raises(pa.ArrowInvalid, match="Float value 1.5 was truncated"):
1650+
with tm.external_error_raised(pa.ArrowInvalid):
16511651
array.to_pandas(types_mapper={pa.float64(): ArrowDtype(pa.int64())}.get)
16521652

16531653

0 commit comments

Comments
 (0)