将数据框转换为字典时,如何仅将数据框架的一部分提取为关键?
这是数据框的外观。它是从santiment中检索出来的。
ethSpent
datetime
2020-04-17 00:00:00+00:00 0.0
2020-04-17 01:00:00+00:00 0.0
df.todict()
这是什么一对键和值看起来
Timestamp('2021-04-14 20:00:00+0000', tz='UTC'): 0.0,
只有我如何在没有时间戳和TZ ='utc'的情况下提取日期时间?
Here is what the dataframe looks like. It was retrieved from Santiment.
ethSpent
datetime
2020-04-17 00:00:00+00:00 0.0
2020-04-17 01:00:00+00:00 0.0
df.todict()
Here is what one pair of key and value looks like
Timestamp('2021-04-14 20:00:00+0000', tz='UTC'): 0.0,
How do I only extract the datetime without the Timestamp and tz='UTC'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以这样做,而无需更改原始
df
。就像在评论中所问的一样。您可以使用
.Reset_index()
,然后像以前分配:You could do it like this without changing the original
df
.Like in the comments asked. You can just go with
.reset_index()
and then assigning like before: