I'm new to both Python and Facebook Prophet, so this may be a no-brainer, but I haven't been able to find an answer online.
I have a 7-column csv file. One column contains a datestamp ('ds') column with daily increments, and the other 6 columns ('y1', 'y2', 'y3', etc.) contain 6 variables whose values align with the datestamps.
Instead of creating six different two-column csv files and running Prophet six different times (predicting only one variable at a time), I'd like to find a way to predict all six variables at once. Here's what I'm trying:
df = pd.read.csv('example_file.csv')
cols = ['y1','y2','y3','y4','y5','y6']
results = []
for col in cols:
subdf = df[['ds', col]].dropna()
m = Prophet()
m.fit(subdf)
result = m.predict(m.make.future.dataframe(periods = 90))
results.append(result)
df.predict = pd.concat(results, axis=1)
df.predict.to_csv('example_file.csv')
When I run it, I'm getting the following error:
ValueError: Dataframe must have columns 'ds' and 'y' with the dates and values respectively.
Any insight/help would be much appreciated. Thanks!
Sorry I wanted to comment but I don't have sufficient reputation yet. Please rename your columns in the loop
subdf = subdf.rename(columns={'ds':'ds', col:'y'})
Prophet imposes the strict condition that the input columns be named ds (the time column) and y (the metric column).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With