Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select multiple columns in pandas data frame with column index as sequential number

I am trying to extract the 7th to 14th columns in a data frame. However

df[0:3] only gives the 1st to 3rd rows.

Does anyone knows what should I do if I want to find out the columns?

I know how to do it with column names such as df['a'] but as the names are too many, I just want to type something like df[,7:14] in R.

Thanks in advance.

like image 838
lsheng Avatar asked Mar 03 '14 03:03

lsheng


1 Answers

Looks that I found it....

By using iloc..

df.iloc[:,your_col_index]
like image 180
lsheng Avatar answered Oct 03 '22 17:10

lsheng