Skip to content

Instantly share code, notes, and snippets.

@StrikingLoo
Last active December 18, 2018 22:19
Show Gist options
  • Select an option

  • Save StrikingLoo/20268994c7c476cda214c7d050f073f3 to your computer and use it in GitHub Desktop.

Select an option

Save StrikingLoo/20268994c7c476cda214c7d050f073f3 to your computer and use it in GitHub Desktop.
#returns only the rows where x is >5, by reference (writing on them alters original df)
df2 = df.loc[df['x'] > 5]
#returns only the rows where x is 0,1,2,3 or 4, by reference
df3 = df.x.isin(range(4))
#returns only the rows where x is >5, by read-only reference (can't be written on)
df4 = df[df['x']>5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment