Skip to content

Instantly share code, notes, and snippets.

@shanealynn
Last active November 15, 2019 10:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanealynn/b27fbdce4688f06108a32c767b65fc3f to your computer and use it in GitHub Desktop.
Save shanealynn/b27fbdce4688f06108a32c767b65fc3f to your computer and use it in GitHub Desktop.
# Select rows with index values 'Andrade' and 'Veness', with all columns between 'city' and 'email'
data.loc[['Andrade', 'Veness'], 'city':'email']
# Select same rows, with just 'first_name', 'address' and 'city' columns
data.loc['Andrade':'Veness', ['first_name', 'address', 'city']]
# Change the index to be based on the 'id' column
data.set_index('id', inplace=True)
# select the row with 'id' = 487
data.loc[487]
@olagunjurahman
Copy link

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment