If you have two time series as equally-indexed pd.Series objects, you can simply subtract them, determine the signs of the differences (which tells you which is higher), determine the differences of these signs over time (which tells you whether or not the order of the two has changed) and look at whenever those sign differences are non-zero (which tells you that there was a change in the order, i.e. an intersection of the graph). The following code computes the indices of all timesteps between whose and their respective predecessors there were intersections:
发布评论
评论(1)
如果您有两个时间序列为同等索引
pd.series
对象,则可以简单地减去它们,确定差异的符号(告诉您哪个更高),确定这些标志的差异时间(告诉您两者的顺序是否已更改),并每当这些符号差异不为零(告诉您顺序有变化,即图表的交集)。以下代码计算其各自的前任之间的所有时间段的索引。If you have two time series as equally-indexed
pd.Series
objects, you can simply subtract them, determine the signs of the differences (which tells you which is higher), determine the differences of these signs over time (which tells you whether or not the order of the two has changed) and look at whenever those sign differences are non-zero (which tells you that there was a change in the order, i.e. an intersection of the graph). The following code computes the indices of all timesteps between whose and their respective predecessors there were intersections: