Question: I have to read some columns/lines from a csv file in Python. I thought to use Pandas, but i don't reach to do this:
Read the columns between number 8 and number 11 (included), and the lines between number 25 and 30.
I have already seen here 

[How to use pandas to select certain columns in csv file](https://stackoverflow.com/questions/56888607/how-to-use-pandas-to-select-certain-columns-in-csv-file)

But it hasn't helped me so far.
Thank you for your help.

```
import pandas as pd
df = pd.read_csv('panels.csv' , usecols = ['col1','col2'])
df

```

Answer: 
Use [`numpy.r_`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.r_.html) for concanecate indices:

```
df = pd.read_csv('panels.csv' , usecols = ['col1','col2'])

df = df.iloc[np.r_[8:12, 25:31]]

```

Or if want use only `iloc` function for seelct by positions is necessary [`Index.get_indexer`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.get_indexer.html) for positions of columns names:

```
df = pd.read_csv('panels.csv')

df = df.iloc[np.r_[8:12, 25:31], df.columns.get_indexer(['col1','col2'])]

```

---

Sample:

```
np.random.seed(2019)
df = pd.DataFrame(np.random.randint(10, size=(35, 3)), columns=['col1','col2', 'col3'])
df.to_csv('panels.csv', index=False)

```

---

```
df1 = pd.read_csv('panels.csv' , usecols = ['col1','col2'])

df1 = df1.iloc[np.r_[8:12, 25:31]]
print (df1)
    col1  col2
8      6     6
9      1     3
10     0     2
11     1     8
25     7     0
26     9     0
27     2     9
28     4     7
29     0     5
30     4     1

```

---

```
df2 = pd.read_csv('panels.csv')

df2 = df2.iloc[np.r_[8:12, 25:31], df2.columns.get_indexer(['col1','col2'])]
print (df2)
    col1  col2
8      6     6
9      1     3
10     0     2
11     1     8
25     7     0
26     9     0
27     2     9
28     4     7
29     0     5
30     4     1

```

---

```
df3 = pd.read_csv('panels.csv')

df3 = df3.loc[df3.index[np.r_[8:12, 25:31]], ['col1','col2']]
print (df3)
    col1  col2
8      6     6
9      1     3
10     0     2
11     1     8
25     7     0
26     9     0
27     2     9
28     4     7
29     0     5
30     4     1

```
Try the following, it is in general approach. You can change accordingly. I Hope this would help.

```
data[['Rank','Title']].iloc[list(range(8,12))+list(range(25,31))]

```

Here instead of Rank and Title, you can pass whatever column names you want to select.