Delete rows in dataframe based on column values
<p>I need to rid myself of all rows with a null value in column C. Here is the code:</p>

<pre><code>infile="C:\****"

df=pd.read_csv(infile)    

A   B   C   D
1   1   NaN 3
2   3   7   NaN
4   5   NaN 8
5   NaN 4   9
NaN 1   2   NaN
</code></pre>

<p>There are two basic methods I have attempted.</p>

<p>method 1:
source: <a href="https://stackoverflow.com/questions/13413590/how-to-drop-rows-of-pandas-dataframe-whose-value-of-certain-column-is-nan">How to drop rows of Pandas DataFrame whose value in certain columns is NaN</a></p>

<pre><code>df.dropna()
</code></pre>

<p>The result is an empty dataframe, which makes sense because there is an NaN value in every row.  </p>

<pre><code>df.dropna(subset=[3])
</code></pre>

<p>For this method I tried to play around with the subset value using both column index number and column name.  The dataframe is still empty.</p>

<p>method 2:
source: <a href="https://stackoverflow.com/questions/18172851/deleting-dataframe-row-in-pandas-based-on-column-value">Deleting DataFrame row in Pandas based on column value</a></p>

<pre><code>df = df[df.C.notnull()]
</code></pre>

<p>Still results in an empty dataframe!</p>

<p>What am I doing wrong?</p>