What\'s the most efficient way to calculate the time-weighted average of a TimeSeries in Pandas 0.8? For example, say I want the time-weighted average of df.y - df.x>
df.y - df.x>
You can convert df.index to integers and use that to compute the average. There is a shortcut asi8 property that returns an array of int64 values:
df.index
asi8
np.average(df.y - df.x, weights=df.index.asi8)