title: Python Pandas find non zero indices
body: <p>Hi I'm trying to use pandas to tidy up a DataFrame. It is imported from a spreadsheet and has some empty rows and columns.</p>
  
  <p>I thought I could use</p>
  
  <p><code>df.apply(numpy.nonzero(),axis=1)</code> and <code>df.apply(numpy.nonzero(),axis=0)</code> to get the indices of the non-zero columns so that I could remove there inverses from the DataFrame.That gives me a list of tuples I'm not clear how to get at.</p>
  
  <p><code>numpy.nonzero(df)</code> produces an array of all the non-zero values but I'm not sure how to feed that value into an <code>all()</code> function.</p>
  
  <p>My question is what would be the best and quickest way of removing those index rows and columns from a DataFrame that are all empty (or all have a value such as N/A)s</p>
  
  <p>Thanks</p>
  
  <p>EDIT example of the source spreadsheet added</p>
  
  <pre><code>&lt;bound method DataFrame.head of             0         1         2  3         4         5  6         7         8  9   \
  0                                                                                     
  1   some title                                                                        
  2         date     38477                                                              
  3                                                                                     
  4                                                                                     
  5                   cat1                   cat2                   cat3                
  6                      a         b            c         d            e         f      
  7                                                                                     
  8            Z  167.9404  151.1389      346.197  434.3589     336.7873  80.52901      
  9            X   220.683   56.0029     73.73679  428.8939     483.7445  251.1877      
  10           C  433.0189  390.1931     251.6636  418.6703     12.21859   113.093      
  11                                                                                    
  12           V  226.0135  418.1141     310.2038  153.9018     425.7491  73.08073      
  13           W   295.146  173.2747     2.187459  401.6453     51.47293   175.387      
  14           S  306.9325  157.2772     464.1394   216.248     478.3903   173.948      
  15           A  19.86611  73.11554      320.078  199.7598     467.8272  234.0331      
  16                                                                                    
  17           F   225.511  20.97305     425.8834  190.1625     123.9103  116.3803      
  18           R  130.4728  96.08118     428.2007  22.46184     26.34678  359.5625      
  19           E  239.1516  439.7733     197.7023  121.6911     195.0169  264.5553      
  20           W  227.1557  471.8341     165.3779  151.7552     314.7827  367.0868      
  </code></pre>
  
  <p>this is the def I'm using at the moment but it feels very clunky</p>
  
  <pre><code>def nulls(x):
      ''' the NULS section to clear all nulls from the 
  DataFrame'''
      # Empty Rows
      nr = [i for i in x.index if all(str(k) in '' for k in x.ix[i])]
      # Non Empty Rows
      r = [i for i in x.index if i not in nr]
      # Empty columns
      nc = [j for j in range(x.shape[1]) if all(str(k) in '' for k in x[j])]
      # Non Empty Columns
      c = [j for j in range(x.shape[1]) if j not in nc]
      # Subset the non-empties
      x=x.ix[r,c]
      x=x.reindex()
      return(x)
  </code></pre>