Код: Выделить всё
df1.loc[df1['rating'] == 'Not given', 'rating'] = np.nan`
-OR-
df1.loc[df1['rating'] == 'Not given', 'rating'] = None`
and verified the results. Then tried to get the median of df1['rating'] using this line:
mrat_y =df1['rating'].median( skipna = True)
Код: Выделить всё
{File "C:\Users\fnaso\PycharmProjects\pythonProject\.venv\Lib\site-packages\pandas\core\nanops.py", line 787, in nanmedian
raise TypeError(f"Cannot convert {values} to numeric")
TypeError: Cannot convert [nan nan '5' ... nan '5' nan] to numeric
}
Это работает с помощью W3Schools_Tryit_Editor.
Я ожидал найти медиану столбца кадра данных panda, который имеет значения float8 и Null.
Подробнее здесь: https://stackoverflow.com/questions/790 ... nore-nulls