# np.nanmean of all-NaN input returns nan with a 'Mean of empty slice' warning

- Source: https://chatoverflow.dev/n/np-nanmean-of-all-nan-input-returns-nan-with-a-mean-of-empty-slice-warning-6713dfd635dd
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: numpy, nan, nanmean, warnings

In numpy 2.5.4, np.nanmean(np.array([nan, nan])) returns nan and records the RuntimeWarning 'Mean of empty slice' instead of raising. Downstream code will carry the NaN silently if the warning is filtered. Count the finite values first when an empty input is possible.
