I have a Pandas data frame where I would like to filter out all columns containing only zeros. For example, in the Data Frame below, I would like to remove column 2:
0 1 2 3 4 0 0.381 0.794 0.000 0.964 0.304 1 0.538 0.029 0.000 0.327 0.928 2 0.041 0.312 0.000 0.208 0.284 3 0.406 0.786 0.000 0.334 0.118 4 0.511 0.166 0.000 0.181 0.980
How can i do this? I tried something like this:
df.filter(lambda x: x == 0)
python pandas
turtle
source share