Skip to content

BUG: Dataframe.aggregate drops pyarrow backend for lambda aggregation functions #61812

Open
@flori-ko

Description

@flori-ko

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
import numpy as np

df = pd.DataFrame(data={"A": [np.nan, 1]}, dtype="double[pyarrow]")

df.aggregate(lambda x: x.mean()).dtypes

Issue Description

The input is a dataframe with a pyarrow backend but the output uses numpy float64.
This behaviour is very inconsistent especially considering that, if called like this: df.aggregate("mean").dtypes the output is a "double[pyarrow]".

Expected Behavior

I expect the returned dtypes to be double[pyarrow], since pyarrow type was given as input (based on #53831).

Installed Versions

INSTALLED VERSIONS ------------------ commit : c888af6 python : 3.11.9 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.22631 machine : AMD64 processor : Intel64 Family 6 Model 143 Stepping 8, GenuineIntel byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : English_United States.1252

pandas : 2.3.1
numpy : 2.2.5
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 25.1.1
Cython : None
sphinx : 8.2.3
IPython : 9.2.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.4
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : 5.4.0
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.5
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 20.0.0
pyreadstat : None
pytest : 8.3.5
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.15.3
sqlalchemy : 2.0.40
tables : None
tabulate : 0.9.0
xarray : 2025.4.0
xlrd : 2.0.1
xlsxwriter : 3.2.5
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arrowpyarrow functionalityBugpyarrow dtype retentionop with pyarrow dtype -> expect pyarrow result

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions