关于pandas 里替换值的问题,请大神帮忙
本帖最后由 futui 于 2022-12-10 17:40 编辑data = [,
,
,
,
,
]
我想把None 全部替换为1或其它什么数,用df.fillna()函数没效,请大神帮忙
#什么叫 没效???
df = pd.DataFrame(data)
df
0 1 2 3 4 5 6 7 8 9 10
0NoneNoneNone23.4325.7728.3525.5223.3022.98 NaN NaN
1NoneNoneNone NaN NaN39.1737.7940.1839.3538.4137.86
2NoneNoneNone NaN NaN48.8348.3048.5249.2649.8248.73
3NoneNoneNone NaN NaN62.8062.2163.9065.7365.4064.71
4NoneNoneNone NaN NaN33.6234.2434.5133.4036.0035.10
5NoneNoneNone NaN NaN48.4847.4746.9947.2046.1444.70
df.fillna(1)
0 1 2 3 4 5 6 7 8 9 10
0 1 1 123.4325.7728.3525.5223.3022.98 1.00 1.00
1 1 1 1 1.00 1.0039.1737.7940.1839.3538.4137.86
2 1 1 1 1.00 1.0048.8348.3048.5249.2649.8248.73
3 1 1 1 1.00 1.0062.8062.2163.9065.7365.4064.71
4 1 1 1 1.00 1.0033.6234.2434.5133.4036.0035.10
5 1 1 1 1.00 1.0048.4847.4746.9947.2046.1444.70
页:
[1]