How would I count the number of days based on months with zero data?
<p>I'm writing a script in which I read in a csv with several columns and rows. I need the script to total the values in each column for a single row and return which columns have a value of zero for the row. Here's an example of what the data looks like, there are several other columns but these are the columns of interest for my question:</p>

<pre><code>    JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
     0   0   5   5   0   5   5   5   5   0   0   0
</code></pre>

<p>this is what I have so far:</p>

<pre><code>    import pandas as pd
    import os

    os.chdir('C:\\users\\vroland\\desktop\\RR_WMD\\WUdata')

    fout=open("WUinput.csv","a")
    #read water use file
    df=pd.read_csv("WUtest.csv")
    #Header &amp; months with zero values
    cols=df.columns
    #Boolean array of columns with zero values
    bt=df.apply(lambda x: x==0)
    #List months with zero values
    zar=bt.apply(lambda x:list(cols[x.values]),axis=1)
</code></pre>

<p>I've tried a combination of ways including <code>if</code> statements, but i keep getting an error stating my conditional statement is ambiguous so I'm trying another route. So this is what i have now to go along with the block of code above:</p>

<pre><code>   a=30
   b=31
   c=28
   num_days=pd.DataFrame({'JAN':[b],'FEB':[c],'MAR':[b],'APR':[a],'MAY':[b],
                          'JUN':[a],'JUL':[b],'AUG':[b],'SEP':[a],'OCT':[b],
                          'NOV':[a],'DEC':[b]})
</code></pre>

<p>The idea is to use the values returned in <code>zar</code> to look up the appropriate day value in my data frame <code>num_days</code>. Return this value and calculate the total number of days with a value of zero. </p>

<p>well, I would get rid of the "fout" line.  You don't seem to write to that file, and it doesn't need to be open to use the "read_csv" feature of pandas.  then you can go through each row and find what's zero, and what isn't</p>

<pre><code>returnArray = []
i=0
while i &lt; len(df.values):
    j=14 #since user only cares about column 14-26
    while j &lt; len(df.values[i]):
        if df.values[i][j] == 0:
            returnArray.append([i,j])
        j=j+1
    i=i+1
</code></pre>

python pandas