2. Indexing, selecting, assigning reference


1. Index-based selection

reviews.iloc[0]
reviews.iloc[:, 0]
reviews.iloc[:3, 0]
reviews.iloc[1:3, 0]
reviews.iloc[[0, 1, 2], 0]
reviews.iloc[-5:]

2. Label-based selection

reviews.loc[0, 'country']
reviews.loc[:, ['taster_name', 'taster_twitter_handle', 'points']]

3. Manipulating the index

reviews.set_index('title')
reviews.loc[(reviews.country == 'Italy') & (reviews.points >= 90)]

reviews.loc[reviews.country == 'Italy']

reviews.loc[reviews.country.isin(['Italy', 'France'])]

reviews.loc[reviews.price.notnull()]

你可能感兴趣的:(2. Indexing, selecting, assigning reference)