python - pandas delete the 0 appears most times -


i have dataframe this:

a   b   c   d 1   0   0   0 0   1   0   7 5   2   0   4 6   3   0   0 0   0   8   8 0   7   7   7 0   0   0   1 

1: fow each row, if counts of 0 >90% of column counts(in case: mean: 0.9*4 ), delete row.

2: fow each column, if counts of 0 >90% of row counts(in case: mean: 0.9*7 ), delete column.

i guess want like:

mask_rows = pd.dataframe.sum(df == 0, axis=1) > 0.9*len(df.columns) mask_cols = pd.dataframe.sum(df == 0, axis=0) > 0.9*len(df.columns) 

this creates mask following interpretation of question...


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -