I have a dataFrame with rows and columns that sum to 0.
A B C D
0 1 1 0 1
1 0 0 0 0
2 1 0 0 1
3 0 1 0 0
4
df.loc[row_indexer, column_indexer] allows you to select rows and columns using boolean masks:
In [88]: df.loc[(df.sum(axis=1) != 0), (df.sum(axis=0) != 0)]
Out[88]:
A B D
0 1 1 1
2 1 0 1
3 0 1 0
4 1 1 1
[4 rows x 3 columns]
df.sum(axis=1) != 0 is True if and only if the row does not sum to 0.
df.sum(axis=0) != 0 is True if and only if the column does not sum to 0.