Reputation: 33
I have a dataframe with customer data, and the customer name is in a column called "customer". I also have a list of "members". Some of the customers are also in the members list, but some are not. If the customer is a member, I want it to be TRUE, if not, then FALSE.
Here's what I have:
df[customer].isin([members])
but the error is telling me "unhashable type: 'list' ".
I've also tried:
df[customer] in [members]
and the error tells me "arrays were different lengths: 118816 vs 1171"
Any help would be appreciated!
Upvotes: 2
Views: 10630
Reputation: 1068
You have an extra set of square brackets around members
in your call to df['customer'].isin()
. Also, you don't have quotes around the column name customer
. Your code should look like:
df['customer'].isin(members)
Upvotes: 3