Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to learn forecast from

https://facebook.github.io/prophet/docs/quick_start.html#python-api

then let say, I use this df

df = pd.read_csv("https://datahub.io/core/natural-gas/r/daily.csv").iloc[-1000:]

after that, I run this code

m = Prophet()
m.fit(df)

it shows error ValueError: Dataframe must have columns "ds" and "y" with the dates and values respectively. I believe that this df already in a proper ds as datestamp and y as numerical

then, I'm trying to run something from another option to lowercase the CSV file but it won't change

Your Source dataset column names are not compatible with the Prophet(), So you've to change the names and format it correctly to fit the dataframe into Prophet.

df = pd.read_csv("https://datahub.io/core/natural-gas/r/daily.csv").iloc[-1000:]
new_df=df[['Date','Price']]
new_df['Date']=pd.to_datetime(new_df['Date'])
new_df.rename(columns = {'Date':'ds'}, inplace = True)
new_df.rename(columns = {'Price':'y'}, inplace = True)
m = Prophet()
m.fit(new_df)

What I think is that column name might be an issue here, because the columns of this csv file are Date & Price

Because as it's mentioned in the docs of the API

The input to Prophet is always a dataframe with two columns: ds and y.

And they never said that, we can name it as we want.

So maybe try renaming it and then use it with the API

Let me know if it works or not, if it didn't then we'll search for another solution

Thank you

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.