The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()?
Question:
The Code
indices =pd.Series(df_small)
indices[ : 5]
The Error
The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
Answers:
The reason might be that your dataframe df_small might have more than one column i.e it is not of Series datatype rather its a DataFrame, hence it is showing that error.
Try with only one column and you might not face the above error. For eg
indices = pd.Series(df_small.col1)
The Code
indices =pd.Series(df_small)
indices[ : 5]
The Error
The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
The reason might be that your dataframe df_small might have more than one column i.e it is not of Series datatype rather its a DataFrame, hence it is showing that error.
Try with only one column and you might not face the above error. For eg
indices = pd.Series(df_small.col1)