I am trying to read different tabs from an excel file. For each tab I a want to perform a linear regression that returns a function (1st order polynom) I want to store the function under the name of tab or the data frame
import pandas as pd
import numpy as np
dfs = pd.read_excel(r'Prod.xlsx', sheet_name=None)
for df in dfs:
func = np.poly1d(np.polyfit(dfs[df].P, dfs[df].Q, 1))
def df(x):
return func(x)
I would like to have a function with an individual name for regression each of the sheets. I tried also
for df in dfs:
df = np.poly1d(np.polyfit(dfs[df].P, dfs[df].Q, 1))
but the problem is that df is being overwritten!