> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Use_iloc

#### Sourcery rule id: `use_iloc`

#### Description

Use the [`.iloc`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.iloc.html) attribute for index-based selection


#### Before

```python
df: pandas.DataFrame
data = df[1]
```

#### After

```python
df: pandas.DataFrame
data = df.iloc[1]
```



#### Explanation

Using 'iloc' is optimized for selecting data in Pandas based on index position
(https://pandas.pydata.org/pandas-docs/stable/user_guide/10min.html#selection).
This rule replaces the generic indexing with 'iloc' for index-based selection.

#### Before:
```python
data = df[5]
```

#### After:
```python
data = df.iloc[5]
```
