From bb4a4abcfaff64298b5a32157102bbf908c062ca Mon Sep 17 00:00:00 2001 From: PenguinPen <98591579+PenguinPen@users.noreply.github.com> Date: Thu, 6 Mar 2025 10:29:35 +1000 Subject: [PATCH 1/2] Add inference type info to apply --- pandas/core/frame.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 28485bf5fdfd8..377c60fa116e0 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -10286,7 +10286,10 @@ def apply( either the DataFrame's index (``axis=0``) or the DataFrame's columns (``axis=1``). By default (``result_type=None``), the final return type is inferred from the return type of the applied function. Otherwise, - it depends on the `result_type` argument. + it depends on the `result_type` argument. The return type of the applied + function is inferred based on the first computed result obtained after + applying the function to a Series object. + Parameters ---------- From c2745a1e80940b10b831d18bea4ab2fe13e73bf7 Mon Sep 17 00:00:00 2001 From: PenguinPen <98591579+PenguinPen@users.noreply.github.com> Date: Thu, 6 Mar 2025 10:57:26 +1000 Subject: [PATCH 2/2] DOC: Add inference type information to Dataframe Apply --- pandas/core/frame.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 377c60fa116e0..c862b7dbaf973 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -10286,10 +10286,9 @@ def apply( either the DataFrame's index (``axis=0``) or the DataFrame's columns (``axis=1``). By default (``result_type=None``), the final return type is inferred from the return type of the applied function. Otherwise, - it depends on the `result_type` argument. The return type of the applied - function is inferred based on the first computed result obtained after + it depends on the `result_type` argument. The return type of the applied + function is inferred based on the first computed result obtained after applying the function to a Series object. - Parameters ----------