Reputation: 2089
I am slicing a dataframe in several subsets. To do that I used query because more efficient in my case.
I translated this
df2=df1[(~df1['ColA'].isnull()) & (df1['colB'].isnull())]
in
df2=df1.query("(ColA==ColA) & (ColB != ColB)")
but how do I translate this using query?
df3=df1[~((~df1['ColA'].isnull()) & (df1['ColB'].isnull()))]
Upvotes: 1
Views: 2526
Reputation: 323316
Just need to change the condition like , logic reversed from and to or
df1.query("(ColA!=ColA) | (ColB == ColB)")
Upvotes: 1