Skip to content

Instantly share code, notes, and snippets.

@shanealynn
Last active November 26, 2020 03:04
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save shanealynn/3cd4c410ca1514dd9575443ab1b08a06 to your computer and use it in GitHub Desktop.
# Multiple row and column selections using iloc and DataFrame
data.iloc[0:5] # first five rows of dataframe
data.iloc[:, 0:2] # first two columns of data frame with all rows
data.iloc[[0,3,6,24], [0,5,6]] # 1st, 4th, 7th, 25th row + 1st 6th 7th columns.
data.iloc[0:5, 5:8] # first 5 rows and 5th, 6th, 7th columns of data frame (county -> phone1).
@dragz17
Copy link

dragz17 commented Jun 2, 2018

How if like this.
Data.iloc[x,:7]
I want to make x (row) in range 0:5 and 6:7

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