我想在每分钟结束时对每只股票进行最后一次观察。我的高频数据框如下所示:
+-----+--------+-------+----------+----------+----------+
|stock| date | hour | minute | second | price |
+-----+--------+-------+----------+----------+----------+
VOD | 01-02 | 10 | 13 | 11 | 85.35 |
VOD | 01-02 | 10 | 13 | 12 | 85.75 |
VOD | 01-02 | 10 | 14 | 09 | 84.35 |
VOD | 01-02 | 10 | 14 | 16 | 82.85 |
VOD | 01-02 | 10 | 14 | 26 | 85.65 |
VOD | 01-02 | 10 | 15 | 07 | 84.35 |
... ... ... .... ... ...
ABC | 01-02 | 11 | 13 | 11 | 25.35 |
ABC | 01-02 | 11 | 13 | 15 | 25.39 |
ABC | 01-02 | 11 | 13 | 19 | 25.26 |
所需的输出应该像
+-----+--------+-------+-------+-------+
|stock| date | hour | minute| Price |
+-----+--------+-------+-------+-------+
VOD | 01-02 | 10 | 13 | 85.75 |
VOD | 01-02 | 10 | 14 | 85.65 |
VOD | 01-02 | 10 | 15 | 84.35 |
VOD | 01-02 | 10 | 16 | 85.75 |
... ... ... .... ...
ABC | 01-02 | 11 | 13 | 25.26 |
我知道我可能必须使用partitionBy
andorderBy
语法来获得结果,但我对这两个感到困惑。我熟悉groupby
SQL 中的函数。我想知道哪个更类似于groupby
功能。有人可以帮忙吗?