Pandas version checks

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

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

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

Reproducible Example

import pandas as pd

df = pd.DataFrame({"somegroup": ["A", "B", None], "someint": [1, 2, 3]})
df['someint'] = df['someint'].astype('Int64')
df['cumsum'] = df.groupby(['somegroup'])['someint'].transform('cumsum')

print(df.dtypes)
print(df.query("cumsum.isnull()"))


somegroup     object
someint        Int64
cumsum       Float64
dtype: object

somegroup   someint cumsum

```

Issue Description

I noticed that when a GroupBy column contains NaNs and it is a Int64, the resulting transform operation produces a Float64, which then cannot be checked for NaNs.

If I do the same operation with the regular int64 and float64 the isnull check works.

Expected Behavior

df = pd.DataFrame({"somegroup": ["A", "B", None], "someint": [1, 2, 3]}) df['someint'] = df['someint'].astype(int) df['cumsum'] = df.groupby(['somegroup'])['someint'].transform('cumsum')

print(df.dtypes) print(df.query("cumsum.isnull()"))

somegroup object someint int64 cumsum float64 dtype: object

somegroup someint cumsum 2 None 3 NaN

Installed Versions

INSTALLED VERSIONS ------------------ commit : 2e218d10984e9919f0296931d92ea851c6a6faf5 python : 3.10.9.final.0 python-bits : 64 OS : Linux OS-release : 5.15.90.1-microsoft-standard-WSL2 Version : #1 SMP Fri Jan 27 02:56:13 UTC 2023 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8 pandas : 1.5.3 numpy : 1.24.2 pytz : 2022.7.1 dateutil : 2.8.2 setuptools : 65.6.3 pip : 22.3.1 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.10.0 pandas_datareader: None bs4 : 4.11.2 bottleneck : None brotli : None fastparquet : None fsspec : None gcsfs : None matplotlib : 3.7.1 numba : None numexpr : None odfpy : None openpyxl : 3.1.1 pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : None snappy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None zstandard : None tzdata : None

Comment From: abudis

Actually I think this is already flagged as part of this discussion - https://github.com/pandas-dev/pandas/issues/32265.

Closing.