Aryan Orpe
Aryan Orpe

Reputation: 1

TypeError: cannot concatenate object of type '<class 'datetime.datetime'>'; only Series and DataFrame objs are valid

I'm trying to use AWS Amazon Forecast in the Amazon_Forecast_Quick_Start_Guide but am running into an error which I don't know how to fix.

This is the code:

results_df = pd.DataFrame(columns=['timestamp', 'value', 'source'])

for index, row in actuals.iterrows():
    clean_timestamp = dateutil.parser.parse(row['timestamp'])
    results_df = pd.concat({'timestamp' : clean_timestamp , 'value' : row['target_value'], 'source': 'actual'} , ignore_index=True)
for index, row in forecasts_p10_df.iterrows():
    clean_timestamp = dateutil.parser.parse(row['Timestamp'])
    results_df = pd.concat({'timestamp' : clean_timestamp , 'value' : row['Value'], 'source': 'p10'} , ignore_index=True)
for index, row in forecasts_p50_df.iterrows():
    clean_timestamp = dateutil.parser.parse(row['Timestamp'])
    results_df = pd.concat({'timestamp' : clean_timestamp , 'value' : row['Value'], 'source': 'p50'} , ignore_index=True)
for index, row in forecasts_p90_df.iterrows():
    clean_timestamp = dateutil.parser.parse(row['Timestamp'])
    results_df = pd.concat({'timestamp' : clean_timestamp , 'value' : row['Value'], 'source': 'p90'} , ignore_index=True)

pivot_df = results_df.pivot(columns='source', values='value', index="timestamp")

pivot_df.plot(figsize=(15, 7))

This is the error:

TypeError: cannot concatenate object of type '<class 'datetime.datetime'>'; only Series and DataFrame objs are valid

Can someone help me fix this?

I tried running the code but am running into an error.

Upvotes: 0

Views: 86

Answers (0)

Related Questions