【发布时间】:2016-02-10 20:34:40
【问题描述】:
我有两个 pandas 数据框 X 和 Y,每个都包含过去一个月的盘中价格和时间数据。我想在 X 上运行 Y 的 asof join,即每次看到 X 上的更新时,我们都会采用 Y 的现行价格。我想进行日内分析(因为隔夜效应)
我现在的代码是
Y_asof = Y.groupby('Date').apply(lambda x: x.asof(X.index))
但是,这会返回一个错误提示
AttributeError: 'DataFrame' object has no attribute 'asof'
当我运行时它正在工作
Y_asof = Y.apply(lambda x: x.asof(X.index))
X的样本数据:
Mid Date
Time
2015-09-15 13:02:03.000049 7.575392 2015-09-15
2015-09-15 13:02:06.000049 7.575521 2015-09-15
2015-09-15 13:02:08.000049 7.575392 2015-09-15
2015-09-15 13:02:14.000049 7.575521 2015-09-15
2015-09-15 13:02:15.000048 7.575649 2015-09-15
Y的样本数据:
Mid Date
Time
2015-09-15 12:00:00.443000 4.650894 2015-09-15
2015-09-15 12:00:00.443000 4.650899 2015-09-15
2015-09-15 12:00:06.321000 4.650894 2015-09-15
2015-09-15 12:00:06.322000 4.650884 2015-09-15
2015-09-15 12:00:10.839000 4.650894 2015-09-15
有人可以帮忙吗?非常感谢!
【问题讨论】:
-
能否提供一些示例数据?
-
嗨,Alexander,我附上了每个数据集的负责人。注意,完整的数据集是一个月的数据。