我必须为h列做这个吗?
a b c d e f g h j
0 mid low excellent mid stable stable NaN 15.0 A
1 mid high excellent NaN unstable stable stable 10.0 S
2 high low excellent high stable stable mod-stable 10.0 A
3 mid NaN good high stable unstable mod-stable NaN A
4 mid mid excellent high stable stable stable 10.0 A
5 high low good NaN stable stable unstable 15.0 S
6 mid low excellent high stable stable mod-stable 5.0 S
7 high mid excellent mid unstable unstable stable 10.0 S
8 mid high good mid stable stable stable 10.0 S
9 mid low excellent mid unstable stable mod-stable 10.0 S发布于 2022-04-20 15:37:58
用什么手段?如果您使用熊猫或numpy,您可以检查值是pd.NA还是np.nan。如果你像对待文本一样对待它,你可以尝试用str.split来分割它。
for row in rows:
fields = row.split(delim)
if fields[7] == 'NaN':
fields[7] = str(mean)
row = fields.join(delim)文件中使用的delim分隔符
或者其他类似的东西。希望这能回答你的问题,但我不知道你想做什么。
https://stackoverflow.com/questions/71942380
复制相似问题