将字典追加到数据框 [英] append dictionary to data frame

查看:111
本文介绍了将字典追加到数据框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个函数,该函数返回像这样的字典:

I have a function, which returns a dictionary like this:

{'truth': 185.179993, 'day1': 197.22307753038834, 'day2': 197.26118010160317, 'day3': 197.19846975345905, 'day4': 197.1490578795196, 'day5': 197.37179265011116}

我正在尝试将此字典附加到数据框,如下所示:

I am trying to append this dictionary to a dataframe like so:

output = pd.DataFrame()
output.append(dictionary, ignore_index=True)
print(output.head())

不幸的是,数据框的打印导致数据框为空.有什么想法吗?

Unfortunately, the printing of the dataframe results in an empty dataframe. Any ideas?

推荐答案

您没有将值分配给结果.

You don't assign the value to the result.

output = pd.DataFrame()
output = output.append(dictionary, ignore_index=True)
print(output.head())

这篇关于将字典追加到数据框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆