The numpy type will appear as follows, and pandas will automatically convert the data type
In [46]: tmp[0] = np.nan
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-46-1b66276310ce> in <module>
----> 1 tmp[0] = np.nan
ValueError: cannot convert float NaN to integer
numpy has a mean() method but no median() method
In [46]: tmp[0] = np.nan
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-46-1b66276310ce> in <module>
----> 1 tmp[0] = np.nan
ValueError: cannot convert float NaN to integer
Pandas's Series and DataFrame have mean() and median()
In [54]: a = pd.Series(range(10))
In [55]: a
Out[55]:
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
dtype: int64
In [56]: a.mean()
Out[56]: 4.5
In [57]: a.median()
Out[57]: 4.5
If numpy includes nan, the mean value is calculated, and the mean value is nan
pandas will skip nan