|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 futui 于 2022-12-10 17:40 编辑
data = [[None,None,None,23.43,25.77,28.35,25.52,23.3,22.98,,],
[None,None,None,None,None,39.17,37.79,40.18,39.35,38.41,37.86],
[None,None,None,None,None,48.83,48.3,48.52,49.26,49.82,48.73],
[None,None,None,None,None,62.8,62.21,63.9,65.73,65.4,64.71],
[None,None,None,None,None,33.62,34.24,34.51,33.4,36, 35.1],
[None,None,None,None,None,48.48,47.47,46.99,47.2,46.14,44.7]]
我想把None 全部替换为1或其它什么数,用df.fillna()函数没效,请大神帮忙
#什么叫 没效???
df = pd.DataFrame(data)
df
0 1 2 3 4 5 6 7 8 9 10
0 None None None 23.43 25.77 28.35 25.52 23.30 22.98 NaN NaN
1 None None None NaN NaN 39.17 37.79 40.18 39.35 38.41 37.86
2 None None None NaN NaN 48.83 48.30 48.52 49.26 49.82 48.73
3 None None None NaN NaN 62.80 62.21 63.90 65.73 65.40 64.71
4 None None None NaN NaN 33.62 34.24 34.51 33.40 36.00 35.10
5 None None None NaN NaN 48.48 47.47 46.99 47.20 46.14 44.70
df.fillna(1)
0 1 2 3 4 5 6 7 8 9 10
0 1 1 1 23.43 25.77 28.35 25.52 23.30 22.98 1.00 1.00
1 1 1 1 1.00 1.00 39.17 37.79 40.18 39.35 38.41 37.86
2 1 1 1 1.00 1.00 48.83 48.30 48.52 49.26 49.82 48.73
3 1 1 1 1.00 1.00 62.80 62.21 63.90 65.73 65.40 64.71
4 1 1 1 1.00 1.00 33.62 34.24 34.51 33.40 36.00 35.10
5 1 1 1 1.00 1.00 48.48 47.47 46.99 47.20 46.14 44.70
|
|