I have a dataframe "df" like the sample below. I would like to use address and business_id as a unique key, and filter the dataframe so it only has unique records based on the combination of address and business_id. Can anyone suggest how to do that?
Code:
print df[["address","business_id","city"]][1:3]
Sample Data:
address business_id city
1 2824 Milton Rd mLwM-h2YhXl2NCgdS84_Bw Charlotte
2 337 Danforth Avenue v2WhjAB3PIBA8J8VxG3wEg Toronto
除了删除重复项外,您还想使用df.set_index
df.set_index(keys=["address","business_id"])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.