[

## Pandas Data Structures – Overview¶

Let us understand the details with respect to Pandas.

- Pandas is not a core Python module and hence we need to install using pip –
`pip install pandas`

. - It has 2 types of data structures –
`Series`

and`DataFrame`

. `Series`

is a one dimension array while`DataFrame`

is a two dimension array.`Series`

only contains index for each row and one attribute or column.`DataFrame`

contains index for each row and multiple columns.- Each attribute in the DataFrame is nothing but a Series.
- We can perform all standard transformations using Pandas APIs
- We also have SQL based wrappers on top of Pandas where we can write queries.Here are the steps to get started with Pandas Data Structures:
- Make sure Pandas library is installed using
`pip`

. - Import Pandas library –
`import pandas as pd`

- We need to have a collection or data in a file to create Pandas Data Structures.
- Use appropriate APIs on the data to create Pandas Data Structures.
`Series`

for single dimension array.`DataFrame`

for two dimension array.

```
{note}
Typically we use `Series` for list of regular objects or dict and `DataFrame` for list of tuples or list of dicts. Let us use list for `Series` and list of dicts for `DataFrame`.
```

In [1]:

```
!pip install pandas
```

In [2]:

```
import pandas as pd
```

In [3]:

```
sals_l = [1500.0, 2000.0, 2200.00]
```

In [4]:

```
pd.Series?
```

In [5]:

```
sals_s = pd.Series(sals_l, name='sal')
```

In [6]:

```
sals_s
```

Out[6]:

0 1500.0 1 2000.0 2 2200.0 Name: sal, dtype: float64

In [7]:

```
sals_s[:2]
```

Out[7]:

0 1500.0 1 2000.0 Name: sal, dtype: float64

In [8]:

```
sals_ld = [(1, 1500.0), (2, 2000.0), (3, 2200.00)]
```

In [9]:

```
pd.DataFrame?
```

In [10]:

```
sals_df = pd.DataFrame(sals_ld, columns=['id', 'sal'])
```

In [11]:

```
sals_df
```

Out[11]:

id | sal | |
---|---|---|

0 | 1 | 1500.0 |

1 | 2 | 2000.0 |

2 | 3 | 2200.0 |

In [12]:

```
sals_df['id']
```

Out[12]:

0 1 1 2 2 3 Name: id, dtype: int64

]