Pandas version checks
Reproducible Example
import numpy as np
from pandas.core.nanops import nansem
values = np.array(
[
[np.nan, 1.0, 2.0, 3.0, 4.0],
[0.0, np.nan, 2.0, 3.0, 4.0],
[0.0, 1.0, np.nan, 3.0, 4.0],
[0.0, 1.0, 2.0, np.nan, 4.0],
[0.0, 1.0, 2.0, 3.0, np.nan],
]
)
mask = np.array(
[
[False, True, False, False, False],
[False, False, True, False, False],
[False, False, False, True, False],
[False, False, False, False, True],
[True, False, False, False, False],
]
)
result = nansem(values, mask=mask, skipna=False, axis=0) # also happens with axis = 1
print(result) # result: nan
# expected: np.array([np.nan, np.nan, np.nan, np.nan, np.nan])
Issue Description
nansem, contrary to other reductions in nanops, returns a scalar np.nan instead of an array of np.nan in the example above.
Expected Behavior
Returns an array of np.nan.
Installed Versions
Details
INSTALLED VERSIONS
commit : 501e319
python : 3.14.3
python-bits : 64
OS : Linux
OS-release : 6.19.12-200.fc43.x86_64
Version : #1 SMP PREEMPT_DYNAMIC Sun Apr 12 15:26:33 UTC 2026
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : pt_BR.UTF-8
LOCALE : pt_BR.UTF-8
pandas : 3.1.0.dev0+766.g501e319b0b
numpy : 2.4.3
dateutil : 2.9.0.post0
pip : 26.0.1
Cython : 3.2.4
sphinx : 9.1.0
IPython : 9.11.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.14.3
bottleneck : 1.6.0
fastparquet : 2025.12.0
fsspec : 2026.2.0
html5lib : 1.1
hypothesis : 6.151.9
gcsfs : 2026.2.0
jinja2 : 3.1.6
lxml.etree : 6.0.2
matplotlib : 3.10.8
numba : 0.64.0
numexpr : 2.14.1
odfpy : None
openpyxl : 3.1.5
psycopg2 : 2.9.11
pymysql : 1.4.6
pyarrow : 23.0.1
pyiceberg : 0.11.1
pyreadstat : 1.3.3
pytest : 9.0.2
python-calamine : None
pytz : 2026.1.post1
pyxlsb : 1.0.10
s3fs : 2026.2.0
scipy : 1.17.1
sqlalchemy : 2.0.48
tables : 3.11.1
tabulate : 0.10.0
xarray : 2026.2.0
xlrd : 2.0.2
xlsxwriter : 3.2.9
zstandard : 0.25.0
qtpy : None
pyqt5 : None
None
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
Issue Description
nansem, contrary to other reductions in nanops, returns a scalarnp.naninstead of an array ofnp.nanin the example above.Expected Behavior
Returns an array of
np.nan.Installed Versions
Details
INSTALLED VERSIONS
commit : 501e319
python : 3.14.3
python-bits : 64
OS : Linux
OS-release : 6.19.12-200.fc43.x86_64
Version : #1 SMP PREEMPT_DYNAMIC Sun Apr 12 15:26:33 UTC 2026
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : pt_BR.UTF-8
LOCALE : pt_BR.UTF-8
pandas : 3.1.0.dev0+766.g501e319b0b
numpy : 2.4.3
dateutil : 2.9.0.post0
pip : 26.0.1
Cython : 3.2.4
sphinx : 9.1.0
IPython : 9.11.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.14.3
bottleneck : 1.6.0
fastparquet : 2025.12.0
fsspec : 2026.2.0
html5lib : 1.1
hypothesis : 6.151.9
gcsfs : 2026.2.0
jinja2 : 3.1.6
lxml.etree : 6.0.2
matplotlib : 3.10.8
numba : 0.64.0
numexpr : 2.14.1
odfpy : None
openpyxl : 3.1.5
psycopg2 : 2.9.11
pymysql : 1.4.6
pyarrow : 23.0.1
pyiceberg : 0.11.1
pyreadstat : 1.3.3
pytest : 9.0.2
python-calamine : None
pytz : 2026.1.post1
pyxlsb : 1.0.10
s3fs : 2026.2.0
scipy : 1.17.1
sqlalchemy : 2.0.48
tables : 3.11.1
tabulate : 0.10.0
xarray : 2026.2.0
xlrd : 2.0.2
xlsxwriter : 3.2.9
zstandard : 0.25.0
qtpy : None
pyqt5 : None
None