Reputation: 293
df[(df["Variable"]=="% Recycling") & (df["Country"]== ["United Kingdom", "Türkiye", "OECD - Total"])]
I could not understand why would this code give errors.
Upvotes: 2
Views: 38
Reputation: 6642
Try isin
; you also need .loc
:
df.loc[df["Variable"].eq("% Recycling")
& df["Country"].isin(["United Kingdom", "Türkiye", "OECD - Total"])]
or try with query
:
df.query("Variable == '% Recycling' and Country in ['United Kingdom', 'Türkiye', 'OECD - Total']")
Upvotes: 2