I have a pandas data frame like this. Where the index is pd.DatetimeIndex and the columns are timeseries.
x_1 | x_2 | x_3 | |
---|---|---|---|
2020-08-17 | 133.23 | 2457.45 | -4676 |
2020-08-18 | -982 | -6354.56 | -245.657 |
2020-08-19 | 5678.642 | 245.2786 | 2461.785 |
2020-08-20 | -2394 | 154.34 | -735.653 |
2020-08-20 | 236 | -8876 | -698.245 |
I need to calculate the Euclidean distance of all the columns against each other. I.e., (x_1 - x_2), (x_1 - x_3), (x_2 - x_3), and return a square data frame like this: (Please realize that the values in this table are just an example and not the actual result of the Euclidean distance)
x_1 | x_2 | x_3 | |
---|---|---|---|
x_1 | 0 | 123 | 456 |
x_2 | 123 | 0 | 789 |
x_3 | 456 | 789 | 0 |
I tried this resource but I could not figure out how to pass the columns of my df. If understand correctly the example passes the rows as the series to calculate the ED from.