[英]Why the values from my data output as NaN when I use DataFrame for outputting a column?
**Pictures of my code: ** My code/problem **我的代码图片:**我的代码/问题
Question 1: So it's basically the title.问题1:所以它基本上是标题。 I have a data set that I made in .xlsx format that has numeric values for things like population or area, but when I try to output a single column it shows all my values as NaN.
我有一个以 .xlsx 格式制作的数据集,其中包含人口或面积等数值,但是当我尝试输出单个列时,它会将我的所有值显示为 NaN。
Question 2: If I get to solve this problem, how could I convert all the floats from a column into integers?问题 2:如果我解决了这个问题,如何将列中的所有浮点数转换为整数?
Note: I'm coding on Google Colaboratory.注意:我在 Google Colaboratory 上编码。
Population
column does not exist, it's population (2020)
, and population variable already exists (cell 308), what do you try to do in cell 309 with df
? Population
列不存在,它是population (2020)
和人口变量已经存在(单元格 308),您尝试在单元格 309 中使用df
做什么?
data['population (2020)'].astype('int')
(first verify if this column is float
and not str
) data['population (2020)'].astype('int')
(首先验证此列是否为float
而不是str
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.