: list index out of range
Dario
Registered Posts: 9 ✭✭✭✭
This instruction runs fine in the notebook but when I go back to the recipe and execute it it throws this error:
datatype = df.to_dict('records')[0]['datatype']
<class 'IndexError'>: list index out of range
Is there a sort of custom pandas in the recipe that is not the same as the one in the notebook version?
Thanks in advanced for your help.
Dario
Operating system used: linux AWS
Best Answers
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,215 Dataiker
Hi @darioromero
,
The error may suggest the df you have in your recipe is empty. You could try to handle this case :if not df.empty: data_list = df.to_dict('records') datatype = data_list[0]['datatype'] # Perform operations with datatype else: # Handle the case when the DataFrame is empty
-
Thanks Alex. dataframe was empty. Appreciate it.