我有一个数据,其中有两列,一列是描述,另一列是发布位置。我在publishedAt列上应用了排序函数并获得了日期降序排列的输出。这是我的数据框的示例:
\n\n description publishedAt\n13 Bitcoin price has failed to secure momentum in... 2018-05-06T15:22:22Z\n16 Brian Kelly, a long-time contributor to CNBC\xe2\x80\x99s... 2018-05-05T15:56:48Z\n2 The bitcoin price is less than $100 away from ... 2018-05-05T13:14:45Z\n12 Mati Greenspan, a senior analyst at eToro and ... 2018-05-04T16:05:37Z\n52 A Singaporean startup developing \xe2\x80\x98smart bankno... 2018-05-04T14:02:30Z\n75 Cryptocurrencies are set to make a comeback on... 2018-05-03T08:10:19Z\n76 The bitcoin price is hovering near its best le... 2018-04-30T16:26:57Z\n74 In today\xe2\x80\x99s climate of ICOs with 100 billion to... 2018-04-30T12:03:31Z\n27 Investment guru Warren Buffet remains unsold o... 2018-04-29T17:22:19Z\n22 The bitcoin price has increased by around $400... 2018-04-28T12:28:35Z\n68 Bitcoin futures volume reached an all-time hig... 2018-04-27T16:32:44Z\n14 Biotech-company-turned-cryptocurrency-investme... 2018-04-27T14:25:15Z\n67 The bitcoin price has rebounded to $9,200 afte... 2018-04-27T06:24:42Z\nRun Code Online (Sandbox Code Playgroud)\n\n现在我想描述过去 3 小时、6 小时、12 小时和 24 小时。\n我怎样才能找到它?
\n\n谢谢
\n作为 Pandas 中的一个简单解决方案,您可以使用该DataFrame.last(offset)函数。请务必将 PublishedAt 列设置为数据框 DateTimeIndex。一个类似的函数是获取数据帧开头的行DataFrame.first(offset)。
这是使用提供的偏移量的示例:
df.last('24h')
df.last('12h')
df.last('6h')
df.last('3h')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4869 次 |
| 最近记录: |