Skip to content

Instantly share code, notes, and snippets.

@karanjagota
Created July 5, 2019 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karanjagota/25ec6164f072c7f852460cb6de567f0a to your computer and use it in GitHub Desktop.
Save karanjagota/25ec6164f072c7f852460cb6de567f0a to your computer and use it in GitHub Desktop.
gist for my medium blogs ..
# -----------xxxxxxxxxxxxxxxx-----------------
# Q1. Extract only those rows where column_name: 'mpg' is greater than 30 .
df[df['mpg']>30] # or
df.loc[df['mpg']>30]
# ------------xxxxxxxxxxxxx--------------------
# Q2. Extract only those rows where column_name: 'origin' is equal to 'Asia'
df.loc[df['origin']=='Asia']
# -------------------xxxxxxxxxxxxx------------------
# Q3. Select only top 20 rows of the data/dataframe
df.iloc[0:20,]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment