我有熊猫数据帧
date_hour content
0 2016-10-17 00:00:00 [{"81": 0.0, "82": 0.0, "83": 0.0}]
1 2016-10-17 01:00:00 [{"81": 0.0, "82": 0.0, "83": 0.0}]
我想把数据框内容像这样的数据帧
^{pr2}$我怎样才能做到这一点?在
我试过了:
# work for one item, though I can concat them, but it's slow(I have each json of 7k k/v pairs), took 2.5s for each
pd.read_json(df.head(1).content.item(), orient='records')
使用
str[0]
获取第一个元素你可以用pd系列在
apply
函数中,将Series对象中的字典转换为列,然后使用pd.concat
方法将date_hour
列与展开的数据帧绑定:相关问题 更多 >
编程相关推荐