[英]When i add a new column to my dataframe, it shows as NaN
So I needed to add the 'count' value to the dataframe as a new column.所以我需要将“计数”值添加到 dataframe 作为新列。
I used the below code:我使用了以下代码:
count=HC_Pune.groupby('Customer').size()
HC_Pune.sort_values(by='Customer',inplace=True,ascending=True)
BCP.insert(2,'HC',count,True)
BCP.head(2)
This is the output that I get这是我得到的 output
Could someone please help me in clearing this problem as to why I am getting NaN
for the data?有人可以帮我解决这个问题,为什么我要为数据获取
NaN
吗?
From the look of your short output,you passed empty values to count
which are in turn passed to your dataframe.从您的短 output 的外观来看,您将空值传递给
count
,然后将其传递给您的 dataframe。 Take a look at your dataset.看看你的数据集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.