Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
268 views
in Technique[技术] by (71.8m points)

pandas - How to get nulls rows from datafarmes which are in list in python?

I have two data frames in a list now I want to get null rows columns which are specified in another list. I tried to get but getting an error. Any suggestion about how to do it?

l1 = ['b','c']
df_list = [df1,df2]
df1 = 
   a   b   c_r c_c c_d  d  
0  0   q   1    0   0   3  
1  0 NaN   0    0   0   1  
2  0 Nan   0    1   0   4 
3  0   d   0    0   0   5  
4  0 Nan   0    0   1   6 
df2 = 
   a  c    d  b_q b_d c_d
0  0  r    3  1    0   0
1  0  Nan  1  0    0   0
2  0  c    4  0    0   0
3  0  Nan  5  0    1   0
4  0  d    6  0    0   0       

My code:

test_df=[]
for df in df_list:
  for cn in l1:
       test_df.append(df[df[cn].isnull()]) 

  
question from:https://stackoverflow.com/questions/65935346/how-to-get-nulls-rows-from-datafarmes-which-are-in-list-in-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...