Reputation: 129
I have a df where a column contains state names. So df.state.unique
gives me the unique values.
How can I compare it to a complete list/series of states ["State 1", "State 2"]
?
As a result, I would like to get a list all of states don't show up in df.state
(by name, not True/False), such as "Alabama, Florida", for instance.
Upvotes: 0
Views: 115
Reputation: 6132
IIUC, sets are the way to go. Let's say your complete list of states is called states
:
missing_states = set(states) - set(df.state.unique())
Upvotes: 2