Reputation: 103
I have a dataframe , containing a column (User ID) containing enteries : 1,2,3 ... etc and I want to compare those enteries with a list/array and find out which numbers are missing ?
How do I achieve that? How do I compare that user_ID column with an Array (a)
Upvotes: 0
Views: 37
Reputation: 1677
A bit of set-magic would do the trick if you're looking for which numbers are missing from a
in your case:
a = range(1, 101)
# if values in DataFrame are stored as floats/ints
missing_from_range = set(a).difference(data1['user_iD'])
# if values in dataframe are stored as strings/objects
missing_from_range = set(a).difference(data1['user_iD'].astype(int))
Upvotes: 1