Answers for "python loc id in list"

0

python loc id in list

In [30]: df = pd.DataFrame({'subscriber_id':[1,2,3,4,5]})
'''   	subscriber_id
	0              1
	1              2
	2              3
	3              4
	4              5 '''

mask = df['subscriber_id'].isin([2,4,5])
''' 0    False
	1     True
	2    False
	3     True
	4     True '''

df.loc[mask]
'''	   subscriber_id
	1              2
	3              4
	4              5 '''
Posted by: Guest on June-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language