简体   繁体   中英

Difference between two Dataframes with different size in Python

I have to do the difference between two Dataframes with difference size and I don't know how. My code is:

index = pd.DataFrame(np.zeros((348, 128))) 


for i in range(0, 128) : 

     index[i] = np.random.choice(range(len(Valeur[i][0])) , size = 348, replace = False) 

     index[i] = sorted(index[i])

z = pd.DataFrame(np.zeros((435, 128))) 

for j in range(0, 128) : 

    for i in range(0,435) : 

        z[j][i] = i

I would like to have something like zz = pd.DataFrame((87, 128)) with the values of z who are not in index.

Thank you for your time

You can use boolean indexing:

out = z[~z.isin(index).all(1)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM