Pandas .dropna() on specify attribute
<p>I have this code to drop null values from column Type, specifically looking at Dog.</p>

<pre><code>cd.loc[cd['Type'] == 'Dog'].dropna(subset = ['Killed'], inplace = True)
</code></pre>

<p>I would like to dropna when the ['Killed'] column associating with Type = Dog has NaN value.</p>

<p>The code above generate this pandas error:</p>

<pre><code> A value is trying to be set on a copy of a slice from a DataFrame
</code></pre>

<p>Is there another way where can I dropna on ['Killed'] when ['Type'] == 'Dog'?</p>

<p>(This is my first post), sorry if I can't explain properly
Cheers</p>

<p>It sounds like what you are saying is you want to remove rows where Type is "Dog" and Killed is <code>NaN</code>.  So just select the negation of that condition:</p>

<pre><code>cd = cd.loc[~((cd.Type=="Dog") &amp; cd.Killed.isnull())]
</code></pre>

python pandas