(NB: I'm very new to python and this is my first post on Stack Overflow!)
I have a directory that has multiple .csv files, each with a column of Force and a column of Displacement data. I want to perform the same linear regression plot function to each of them without having to change the file name within the .py file. (Ideally I would like each equation to be an output, but for now I'm happy with multiple plots!)
So far I have:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from scipy import stats
values = pd.read_csv('RawData_1.csv')
slope, intercept, r_value, p_value, std_err =
stats.linregress(values['Displacement'],values['Force'])
ax = sns.regplot(x="Displacement", y="Force", data=values, color='b',
line_kws={'label':"y={0:.1f}x+{1:.1f}".format(slope,intercept)})
ax.legend()
plt.show()
I've tried implementing lines from other posts but having no luck. Any help is much appreciated. Thanks :)