df = reviews.loc[:99,['country','variety']] or df = reviews.loc[[1,2,3,4],['country','variety']]
df = reviews.loc[[0,1,10,100],['country','province','region_1','region_2']] 两颜色不能互换,必须index在前
iloc index loc lable
top_oceania_wines = reviews.loc[reviews.country.isin(['Australia', 'New Zealand']))&(reviews.points >= 95)]
top_oceania_wines = reviews[reviews.country.isin(['Australia', 'New Zealand'])&(reviews.points>=95)] #no using of loc
Use the unique function to get a list of unique entries in a column.
countries = reviews.country.unique() returns ##array
countries = reviews.country.
drop_duplicates() #returns series
ser1 = pd.Series([1, 2, 3, 4, 5])
ser2 = pd.Series([4, 5, 6, 7, 8])
ser1[~ser1.isin(ser2)]
ser1[ser1.isin(ser2)]
ser1.isin(ser2)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
focus on what you want to be