Just getting into Python, so hopefully I'm not asking a stupid question here...
So I have a pandas dataframe named "df_complete' with let's say 100 rows, and containing columns named: "type", "writer", "status", 'col a', 'col c'. I want to create/update a new dataframe named "temp_df" and create it based on conditions using "df_complete" values.
temp_df = pandas.DataFrame()
if ((df_complete['type'] == 'NDD') & (df_complete['writer'] == 'Mary') & (df_complete['status'] != '7')):
temp_df['col A'] = df_complete['col a']
temp_df['col B'] = 'good'
temp_df['col C'] = df_complete['col c']
However, when I do this, I got the following error message:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I read this thread and changed my "and" to "&": Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
I also read this thread here to put everything in parenthesis: comparing dtyped [float64] array with a scalar of type [bool] in Pandas DataFrame
But the error is still present. What is causing this? and how can I fix it?
** follow up question ** Also, how can I obtain the index values of those rows that met the condition?