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

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!

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

```
df.iloc[pd.np.r_[1:10, 12:17]]
```

- ServerfaultXchanger
- SuperuserXchanger
- UbuntuXchanger
- WebappsXchanger
- WebmastersXchanger
- ProgrammersXchanger
- DbaXchanger
- DrupalXchanger
- WordpressXchanger
- MagentoXchanger
- JoomlaXchanger
- AndroidXchanger
- AppleXchanger
- GameXchanger
- GamingXchanger
- BlenderXchanger
- UxXchanger
- CookingXchanger
- PhotoXchanger
- StatsXchanger
- MathXchanger
- DiyXchanger
- GisXchanger
- TexXchanger
- MetaXchanger
- ElectronicsXchanger
- StackoverflowXchanger
- BitcoinXchanger
- EthereumXcanger