简体   繁体   English

当我使用 DataFrame 输出列时,为什么我的数据输出中的值是 NaN?

[英]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 上编码。

  1. 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做什么?

  2. 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.

相关问题 我的数据框列输出所有值的 NaN - My dataframe column output NaN for all values Why do I keep getting 'Nan' values when I try to add a column from a csv dataframe to an existing dataframe both opened on pandas? - Why do I keep getting 'Nan' values when I try to add a column from a csv dataframe to an existing dataframe both opened on pandas? 为什么在数据框中创建新列时NaN值显示不正确? - Why NaN values appear incorrectly when creating new column in dataframe? 尝试在Pandas数据框中添加列时,为什么会得到np.NaN值? - Why am I getting np.NaN values when trying to add a column to a Pandas dataframe? Pandas dataframe 列来自包含 NaN 值的数据 - Pandas dataframe column from data containing NaN values 当我向 dataframe 添加新列时,它显示为 NaN - When i add a new column to my dataframe, it shows as NaN 当我将numpy数组转换为Dataframe时,它将值更新为Nan - When i convert my numpy array to Dataframe it update values to Nan 当 notnull、dropna 和?= 'nan' 不起作用时,如何从 dataframe 列中删除 nan 值? - How to remove nan values from a dataframe column when notnull, dropna and != 'nan' don't work? pandas DataFrame based on an existing column data 添加新列时的NaN值 - NaN values when new column is added to pandas DataFrame based on an existing column data 当我转置 dataframe 时,它显示 nan 值 - when i transpose a dataframe, it shows nan values
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM