ValueError: endog has evaluated to an array with multiple columns that has shape (50, 11)

Viewed 1450

I have a dataframe that looks like: enter image description here

and is generated by using panda:

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import statsmodels.api as sm
from statsmodels.formula.api import ols

df = pd.read_excel("C:\\Users\\amlut\\Desktop\\Classes\\Case Studies\\SureFactor_Demand.xlsx")
df = df.dropna()
df.columns = ["Week", "DemandB15", "Demand C17", "Demand D20", "Demand D25", "Demand E26", "Demand F35"]
df.iloc[1,0] = 1
df = df.iloc[1:51]
df.index = range(0,50)

trying to run ols on this dataframe result = ols(formula = "DemandB15 ~ Week", data=df).fit() generates the error:

ValueError: endog has evaluated to an array with multiple columns that has shape (50, 11). This occurs when the variable converted to endog is non-numeric (e.g., bool or str).

There does not appear to be any non-numerics in my dataframe, so I am very confused on this error. I have very little experience with python or panda, so please assume the knowledge of an absolute noob.

0 Answers
Related