简体   繁体   中英

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.

Looks that I found it....

By using iloc..

df.iloc[:,your_col_index]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM