我一直在尝试逐行进行pandas DF的多次下降:
df_clean = df_merged[df_merged.GDP_current != '..']
df_clean = df_clean[df_clean.GDP_growth != '..']
在一条线上有更有效的方法吗?我尝试使用下面的代码,但它不起作用:
df_clean = df_merged['GDP_current' != '..'] | df_merged['GDP_growth' != '..'] | df_merged['GDP_per_capita' != '..']
OR
df_clean = df_merged.drop[df_merged['GDP_growth' == '..'] | df_merged['GDP_current' == '..'] | df_merged['GDP_per_capita' == '..']]
答案 0 :(得分:0)
df_clean = df_merged[(df_merged['GDP_current' != '..']) | (df_merged['GDP_growth' != '..']) | (df_merged['GDP_per_capita' != '..'])]