简体   繁体   English

熊猫数据框追加问题

[英]panda dataframe append issue

Any idea why pandas dataframe append is inserting NaN values for only 3 columns out of 50 columns where as dictionary has the real value知道为什么 Pandas 数据框追加只为 50 列中的 3 列插入 NaN 值,其中字典具有实际值

checking whether dict has proper values or not before appending, its shows real values:在追加之前检查 dict 是否具有正确的值,它显示实际值:

 for x,y in dict.items():
     print(x, '-', y)

but after appending to dataframe its showing as NaN, no clue why its happening.但是在附加到数据帧后,它显示为 NaN,不知道为什么会发生。

df = df.append(dict,ignore_index=True,sort=False)

Any idea where its going wrong ?知道哪里出了问题吗?

dict 必须是数据框或系列

DataFrame.append(df, dict, ignore_index=False, verify_integrity=False, sort=None)

Sorry i wasted a lot of time.抱歉我浪费了很多时间。 i am seeing df.head() and assuming i didnt get the proper data but after seeing df values got inserted properly :)我看到 df.head() 并假设我没有得到正确的数据,但在看到 df 值被正确插入后:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM