Python pandas linear regression groupby

前端 未结 3 1183
青春惊慌失措
青春惊慌失措 2021-01-31 11:48

I am trying to use a linear regression on a group by pandas python dataframe:

This is the dataframe df:

  group      date      value
    A     01-02-201         


        
3条回答
  •  执笔经年
    2021-01-31 12:22

    As a newbie I cannot comment so I will write it as a new answer. To solve an error:

    Runtime Error: ValueError : Expected 2D array, got scalar array instead
    

    you need to reshape delta value in line:

    return np.squeeze(LinearRegression().fit(X, y).predict(np.array(delta).reshape(1, -1)))
    

    Credit stays for you piRSquared

提交回复
热议问题