@@ -10378,6 +10378,7 @@ def apply(
1037810378 ----------
1037910379 func : function
1038010380 Function to apply to each column or row.
10381+
1038110382 axis : {0 or 'index', 1 or 'columns'}, default 0
1038210383 Axis along which the function is applied:
1038310384
@@ -10396,18 +10397,25 @@ def apply(
1039610397
1039710398 result_type : {'expand', 'reduce', 'broadcast', None}, default None
1039810399 These only act when ``axis=1`` (columns):
10399-
10400+
1040010401 * 'expand' : list-like results will be turned into columns.
10402+ Note: The output type is inferred from the first function return value.
10403+ If the first return value is not list-like (e.g., None or NaN), expansion
10404+ will not occur, and the result may be a Series instead of a DataFrame.
10405+ To avoid inconsistent output types, ensure your function returns consistent
10406+ list-like objects (e.g., an empty dict {}) for missing or NaN-like values.
10407+
1040110408 * 'reduce' : returns a Series if possible rather than expanding
1040210409 list-like results. This is the opposite of 'expand'.
1040310410 * 'broadcast' : results will be broadcast to the original shape
1040410411 of the DataFrame, the original index and columns will be
1040510412 retained.
10406-
10413+
1040710414 The default behaviour (None) depends on the return value of the
1040810415 applied function: list-like results will be returned as a Series
1040910416 of those. However if the apply function returns a Series these
10410- are expanded to columns.
10417+ are expanded to columns.
10418+
1041110419 args : tuple
1041210420 Positional arguments to pass to `func` in addition to the
1041310421 array/series.
0 commit comments