user-1
(User 1)
May 17, 2023, 3:41pm
1
This topic was automatically generated from Slack. You can find the original thread here .
My workflow throws an none speaking error:
Pipedream Internal Error
Please retry your event or reach out to Pipedream support at https://pipedream.com/support/
user-1
(User 1)
May 17, 2023, 3:41pm
2
Hi , can you please share more details on your workflow?
What are the steps it in?
user-1
(User 1)
May 17, 2023, 3:41pm
3
Step 1: New Row Added (Instant) from Google Sheets
Step 2: Get Values from same Google Sheet
Step 3: run python code (which worked for a while and then threw this error)
user-1
(User 1)
May 17, 2023, 3:41pm
5
Thanks for the info! So the inputs to the python code are the values from the Google Sheet row?
user-1
(User 1)
May 17, 2023, 3:41pm
6
Can you share your python code here? Feel free to remove any sensitive information
user-1
(User 1)
May 17, 2023, 3:41pm
8
import pandas as pnd
from prophet import Prophet
import json
def handler(pd: “pipedream”):
#get data from previous step. Google Sheet content
df = pnd.DataFrame(pd.steps[“get_values”][“$return_value”], columns=pd.steps[“get_values”][“$return_value”][0])
print (pd.steps[“get_values”][“$return_value”])
print (df.head())
print (df.info ())
print (df.columns)
df.drop(df.tail(2).index,inplace=True )
df.drop(df.head(1).index,inplace=True )
df[‘Datum: Tag.Monat.Jahr’] = pnd.to _datetime(df[‘Datum: Tag.Monat.Jahr’], format =‘%d.%m.%Y’, errors=‘coerce’)
df = df.drop(“Gesamt”, axis=‘columns’)
df = df.drop(“Ø”, axis=‘columns’)
df[‘Anzahl’] = df[‘Anzahl’].str .replace(‘,’, ‘.’).astype(float )
df = df.rename(columns={“Datum: Tag.Monat.Jahr”: “ds”, “Anzahl”: “y”}, errors=“raise”)
m = Prophet(yearly_seasonality=**True**)
m.add_country_holidays(country_name='DE')
m.fit(df)
future = m.make_future_dataframe(periods=7)
forecast = m.predict(future)
forecast['day_of_week'] = forecast['ds'].dt.day_name()
forecast['fact'] = df['y'].reset_index(drop = **True**)
forecast['anomaly'] = 0
forecast.loc[(forecast['fact'] > forecast['yhat_upper']) & (forecast['fact'] < 100), 'anomaly'] = 1
forecast.loc[forecast['fact'] < forecast['yhat_lower'], 'anomaly'] = -1
_#anomaly importances_
forecast['importance'] = 0
forecast.loc[forecast['anomaly'] ==1, 'importance'] = (forecast['fact'] - forecast['yhat_upper'])/forecast['fact']
forecast.loc[forecast['anomaly'] ==-1, 'importance'] = (forecast['yhat_lower'] - forecast['fact'])/forecast['fact']
**return** {"forecast": [forecast.to](http://forecast.to)_numpy().tolist()}
user-1
(User 1)
May 17, 2023, 3:41pm
9
Hi Manuel, if you’re using Python to only export step data, we recommend using this structure instead:
user-1
(User 1)
May 17, 2023, 3:41pm
10
The def handler method is less stable
user-1
(User 1)
May 17, 2023, 3:41pm
11
ok thanks for the Feedback I will try this!