A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.NamedAgg.html below:

pandas.NamedAgg — pandas 2.3.1 documentation

pandas.NamedAgg#
class pandas.NamedAgg(column, aggfunc)[source]#

Helper for column specific aggregation with control over output column names.

Subclass of typing.NamedTuple.

Parameters:
columnHashable

Column label in the DataFrame to apply aggfunc.

aggfuncfunction or str

Function to apply to the provided column. If string, the name of a built-in pandas function.

Examples

>>> df = pd.DataFrame({"key": [1, 1, 2], "a": [-1, 0, 1], 1: [10, 11, 12]})
>>> agg_a = pd.NamedAgg(column="a", aggfunc="min")
>>> agg_1 = pd.NamedAgg(column=1, aggfunc=lambda x: np.mean(x))
>>> df.groupby("key").agg(result_a=agg_a, result_1=agg_1)
     result_a  result_1
key
1          -1      10.5
2           1      12.0

Attributes

aggfunc

Alias for field number 1

column

Alias for field number 0

Methods

count(value, /)

Return number of occurrences of value.

index(value[, start, stop])

Return first index of value.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4