Home > Back-end >  How to compare graphs of 2 time series data
How to compare graphs of 2 time series data

Time:10-10

I have 2 dataframes containing movements of a person and want to compare how similar they are to each other or to be precise how well is person 2 able to copy person 1.

import pandas as pd
fp = pd.read_csv("first_person.csv")
sp = pd.read_csv("second_person.csv")
fp = fp.iloc[: , 1:]
sp = sp.iloc[: , 1:]
#fp.LEFT_SHOULDER_Y.plot(),sp.LEFT_SHOULDER_Y.plot()

#This is what i get when i plot against a particular columns enter image description here

What is want is a list of graphs one by one against each and every column in the dataframe without manually writing the code for each column.

I tried this

enter image description here

But this is not what I want, I want individual graphs for individual column. Also is there a way I can compare how well is person 2 able to copy person 1. Thanks Links to csv files:

first_person.csv - https://drive.google.com/file/d/10BNGtTY8nu8ww4yVUM5bkg8i4ZBUSOnU/view?usp=sharing

second_person.csv - https://drive.google.com/file/d/1RCZ7lbdgTTzgtVPGmLas-7kMTtUOeDXM/view?usp=sharing

CodePudding user response:

To get separate plots, display each plot inside the loop...

import pandas as pd
fp = pd.read_csv("first_person.csv")
sp = pd.read_csv("second_person.csv")
fp = fp.iloc[: , 1:]
sp = sp.iloc[: , 1:]
for x in range(fp.shape[1]):
    fp.iloc[:,x].plot(),sp.iloc[:,x].plot()
    plt.title(fp.columns[x])
    plt.show() ## Added so that each individual plot is shown
  • Related