我正在处理多个时间序列,其中一个操作应用于 anasset_type和price_type取决于source_asset_type,source_price_type和order.
我对构建依赖图的想法很陌生,我需要有关获得预期输出的正确方法的帮助。
假设我有asset_type = AAPL和price_type = USD的时间序列order = 3。Order会让我们知道图的深度,这意味着首先查找asset_type和price_type查找order = 3并检索相应的source_asset_type,source_price_type然后将其用作asset_type和price_type,并将查找相应的source_asset_type,source_price_type并且过程将重复到order 1。作为一个例子,请看下表
+-------------+------------+-------+-------------------+-------------------+
| Asset Type | Price Type | Order | Source Asset Type | Source Price Type |
+-------------+------------+-------+-------------------+-------------------+
| AAPL | USD | 3 | AAPL | EUR |
| AAPL | EUR | 2 | AAPL | CAD |
| AAPL | CAD | 1 | AAPL | CHF |
+-------------+------------+-------+-------------------+-------------------+
我需要一个将最后两行作为输出返回的函数。用户会通过Asset Type = AAPL和。Price Type = USDOrder = 3
目前,我正在使用 Pandas DataFrame 来存储这些依赖项,但我正在寻找更快、计算成本更低的方法来获得结果。
预期产出
一个将检索所有依赖项的函数,如上图所示。存储和检索依赖项的最佳数据类型是什么?为什么?