Subsetting columns that are two groups of consecutive number

by useranon   Last Updated June 12, 2019 07:19 AM - source

Hi I know in R if I have a data frame, df, if I want to just cal the first ten columns and the 12th-17th columns, I can do this: df[,c(1:10,12:17)]. Is there a way to do this in python with the pandas library? What about for just any general ndarray? I am new to python so any help is appreciated!

Tags : python

Answers 1

U might want to check this thread (multiple slicing). U can use the r_ of numpy

df.iloc[[1:10, 12:17]]
June 12, 2019 06:58 AM

Related Questions

how to convert to a list in python

Updated May 21, 2016 08:08 AM

Plot dates along the x axis in seaborn jointplot

Updated February 22, 2017 20:19 PM

Scale Invariant OCR

Updated July 10, 2017 09:19 AM