[英]Pandas Data frame counting how many times certain value appears in column if and only if other columns meet certain condition
I need help with pandas data frame.我需要熊猫数据框的帮助。 Trying to count all rows with a '1' value under particular column A if and only if other columns B,C,D,E,F,G are NOT blank.
当且仅当其他列 B、C、D、E、F、G 不为空时,尝试计算特定列 A 下具有“1”值的所有行。 Any ideas?
有任何想法吗?
Assuming you have a pandas data frame df
with columns ABCDEFG假设您有一个带有 ABCDEFG 列的 Pandas 数据框
df
df_modified=df.dropna(subset = ['A', 'B', 'C', 'D', 'E', 'F', 'G']) #filter out rows that have NA in the listed columns
df_modified['A'].value_counts() #count the rows
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.