How to create a new data frame based on conditions from another data frame
<p>Just getting into Python, so hopefully I'm not asking a stupid question here...</p>

<p>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. </p>

<pre><code>temp_df = pandas.DataFrame()

if ((df_complete['type'] == 'NDD') &amp; (df_complete['writer'] == 'Mary') &amp; (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']
</code></pre>

<p>However, when I do this, I got the following error message:</p>

<pre><code>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
</code></pre>

<p>I read this thread and changed my "and" to "&amp;":
<a href="https://stackoverflow.com/questions/36921951/truth-value-of-a-series-is-ambiguous-use-a-empty-a-bool-a-item-a-any-o">Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()</a></p>

<p>I also read this thread here to put everything in parenthesis: <a href="https://stackoverflow.com/questions/34531416/comparing-dtyped-float64-array-with-a-scalar-of-type-bool-in-pandas-datafram">comparing dtyped [float64] array with a scalar of type [bool] in Pandas DataFrame</a></p>

<p>But the error is still present. What is causing this? and how can I fix it?</p>

<p>** follow up question **
Also, how can I obtain the index values of those rows that met the condition?</p>