[英]iterating over the columns of a dataframe in pandas
我正在嘗試 pandas 中的 dataframe 列中的值的一些直方圖 plot 並且我想在列上循環循環以獲取壓縮代碼
for c in df.columns:
axes[i,0].hist(df[df.num>0].c.tolist())
i +=1
AttributeError: 'DataFrame' object has no attribute 'c'
鏈柱不能在for循環中使用
axes[i,0].hist(df.loc[df.num>0,c].tolist())
您不能對變量使用點表示法。 我想你想要 go 是為了
for c in df.columns:
axes[i,0].hist(df[df.num>0][c].tolist())
i +=1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.