我正在尝试将数据框中的一半列从float转换为int。
这是我正在使用的代码。我的数据框的名称是“ genre_top10”。并且有45列。全部为float 64格式。我想将前27列更改为int。
genre_top10.iloc[:,0:27] = genre_top10.iloc[:,0:27].astype(int)
genre_top10
但是即使在运行以下代码后,我仍然会出现浮动。 cols没有转换为int。
这是原始数据框的一部分。
CVotes10 CVotes09 CVotes08
Action 102144.10 114433.19 150895.32
Adventure 94596.29 105636.63 138482.32
Animation 61960.18 72566.09 104837.64
在这里是运行我的代码之后。
CVotes10 CVotes09 CVotes08
Action 102144.0 114433.0 150895.0
Adventure 94596.0 105636.0 138482.0
Animation 61960.0 72566.0 104837.0