dropna able to accept a list/tuple for axis argument · Issue #924 · pandas-dev/pandas (original) (raw)

rationale:

I sometimes work with square matricies that potentially could have a column (and row) of all na's

I find myself doing:

df.dropna(how='all',axis=0).dropna(how='all',axis=1)

so

df.dropna(how='all',axis=[0,1])

e.g.

_dropna = DataFrame.dropna
def revised_dropna(self, axis = None, **kwargs):
    if isinstance(axis,(list,tuple)):
        return _dropna(_dropna(self,axis=axis[0],**kwargs),axis=axis[1],**kwargs)
    return _dropna(self,axis=axis,**kwargs)
DataFrame.dropna = revised_dropna