File tree Expand file tree Collapse file tree 1 file changed +46
-1
lines changed
Expand file tree Collapse file tree 1 file changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -1259,8 +1259,53 @@ def last(
12591259 )
12601260
12611261 @final
1262- @doc (GroupBy .median )
12631262 def median (self , numeric_only : bool = False ):
1263+ """
1264+ Compute median of groups, excluding missing values.
1265+
1266+ For multiple groupings, the result index will be a MultiIndex
1267+
1268+ Parameters
1269+ ----------
1270+ numeric_only : bool, default False
1271+ Include only float, int, boolean columns.
1272+
1273+ .. versionchanged:: 2.0.0
1274+
1275+ numeric_only no longer accepts ``None`` and defaults to False.
1276+
1277+ Returns
1278+ -------
1279+ Series or DataFrame
1280+ Median of values within each group.
1281+
1282+ See Also
1283+ --------
1284+ Series.groupby : Apply a function groupby to a Series.
1285+ DataFrame.groupby : Apply a function groupby to each row or column of a
1286+ DataFrame.
1287+
1288+ Examples
1289+ --------
1290+
1291+ >>> ser = pd.Series(
1292+ ... [1, 2, 3, 3, 4, 5],
1293+ ... index=pd.DatetimeIndex(
1294+ ... [
1295+ ... "2023-01-01",
1296+ ... "2023-01-10",
1297+ ... "2023-01-15",
1298+ ... "2023-02-01",
1299+ ... "2023-02-10",
1300+ ... "2023-02-15",
1301+ ... ]
1302+ ... ),
1303+ ... )
1304+ >>> ser.resample("MS").median()
1305+ 2023-01-01 2.0
1306+ 2023-02-01 4.0
1307+ Freq: MS, dtype: float64
1308+ """
12641309 return self ._downsample ("median" , numeric_only = numeric_only )
12651310
12661311 @final
You can’t perform that action at this time.
0 commit comments