【发布时间】:2019-01-04 02:01:01
【问题描述】:
我有一个带有时间戳的数据点的 json 文件,需要一个直方图来显示每单位时间的数据点数量。数据格式如下:
database = {
"data": [
{
"timestamp": "Mon Aug 01 00:00:01 +0000 1901",
"user": 796327373691985921,
"text": "blah blah there were no tweets in 1901!?!",
"polarity": 0.2,
"subjectivity": 0.2
},
{
"timestamp": "Mon Aug 01 00:00:10 +0000 1901",
"user": 16548385,
"text": "blah blah blah"
"polarity": 0.0,
"subjectivity": 0.0
}
]
}
等
我无法从字典中选择时间戳项。例如,当我运行此命令时:print(database["data"][0]["timestamp"],它为我提供了一个数据点的时间戳,但是如何根据时间戳将所有推文组织到时间桶中?我怀疑需要一个迭代循环,但我不知道如何继续。再次感谢您!
【问题讨论】:
-
这可能会对您有所帮助。 stackoverflow.com/questions/17050202/…
标签: matplotlib histogram