【发布时间】:2020-05-08 00:21:01
【问题描述】:
我只需要将值从 DF 复制到 dict 以用于将 dict 作为参数的显示函数。
我的数据框在以下摘录中称为databases。
DB_stat_reporting = dict()
report_month = databases.loc[databases['Date'] == reporting_month]
last_year = databases.loc[databases['Date'] == past_year]
report_month
输出:
Date Circ EB Mag bla drive Total Digi
12 2019-12-01 118324 133 1084 4928 17513 141982 23658
我只需要将值传递给字典:
DB_stat_reporting['Circ'] = report_month['Circ']
DB_stat_reporting['Circ']
生产:
12 118324
我需要对其运行一些统计信息,因此它需要保持为 int,但我不希望打印索引或括号等。
预期输出:
118324
这似乎是一件很简单的事情,但我无法做到这一点。
【问题讨论】:
-
你做过研究吗?这似乎是 Pandas 的基本功能。
-
@AMC 我基本上想多了。项目匆忙和大脑冻结。我应该删除这个吗?