Select multiple columns in pandas data frame with column index as serial number

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

df[0:3] gives only 1 to 3 lines.

Does anyone know what should I do if I want to know the columns?

I know how to do this with column names, for example df['a'] , but since there are too many of them, I just want to introduce something like df[,7:14] in R.

Thanks in advance.

+7
python r dataframe
source share
1 answer

Looks like I found it ....

Using iloc ..

 df.iloc[:,your_col_index] 
+11
source share

All Articles