Home Extracting data from pandas based on condition
Reply: 0

Extracting data from pandas based on condition

user551
1#
user551 Published in April 25, 2018, 12:35 am

I have a data frame A = [1,2,3,5,9,8,11,13] and B = [2,1,6,19,16,15,14,12]. I want to is check is whether the criss cross elements of the A and B are equal in any case

For eg: here A[0]==B[1] and B[0]==A[1], this is a criss cross element.

import pandas as pd
df=pd.DataFrame({'A':[1,2,3],'B':[2,1,6]})
if df.loc[0,"A"] == df.loc[1,"B"] & df.loc[1,"A"] == df.loc[0,"B"]:
    print("the values which are equal")
else:
    print("the values which are not equal")
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301545 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO