I ran a simple regression to a database with a product (Product, Volume, Price). It turned perfectly. But I would like to run the same regression on a base with more products, however, I want to be able to choose the product I want to run the regression, see:
ex.
Produto | Volume | Preço A A B B
I want to run regression only on product B.
-
How to do this?
Code
import pandas as pd
Pasta1 = pd.ExcelFile ('Pasta2.xlsx')
Daniel = pd.read_excel (Pasta1, 'Tela')
from scipy.stats import linregress
x= Daniel ['Preço']
y= Daniel ['Volume']
m, b, R, p, SEm = linregress (x, y)
pd.DataFrame ([m , b, R, p, SEm] , columns=['Valores'] , index=['declive',
'ordenada_na_origem', 'coeficiente_de_correlação_(de_Pearson)', 'p-value',
'erro_padrão'])
Result:
Valores
declive: 421.398071
ordenada_na_origem: 1432.443189
coeficiente_de_correlação_(de_Pearson): 0.331966
p-value: 0.000003
erro_padrão: 86.869651