【发布时间】:2018-12-20 00:03:09
【问题描述】:
我有一个包含 600 万行盘中数据的 DataFrame,如下所示:
closingDate Time Last
1997-09-09 11:30:00-04:00 1997-09-09 11:30:00 100
1997-09-09 11:31:00-04:00 1997-09-09 11:31:00 105
我想以矢量化方式规范化我的Last 列,方法是将每一行除以包含当天的第一行的价格。这是我的尝试:
df['Last']/df.groupby('closingDate').first()['Last']
分母是这样的:
closingDate
1997-09-09 943.25
1997-09-10 942.50
1997-09-11 928.00
1997-09-12 915.75
1997-09-14 933.00
1997-09-15 933.00
但是,这个部门只给了我一列 nans。如何在我的 DateTime 索引中关联要广播的部门?
【问题讨论】:
-
使用
df.groupby('closingDate').first()['Last'].values分割
标签: python pandas dataframe group-by