**Pandas**

*chevron_left*

**Creating DataFrames Cookbook**

# Combining multiple Series into a DataFrame in Pandas

*schedule*Mar 5, 2023

*toc*Table of Contents

*expand_more*

**interactive map of data science**

To combine multiple Series into a single DataFrame, use the `concat(~)`

method or the `DataFrame(~)`

constructor.

# Combining Series horizontally

## Series represent columns

To combine two Series horizontally:

```
```

Note the following:

each Series represents a column

the parameter

`axis=1`

for`concat(~)`

is used to perform horizontal concatenation, as opposed to vertical.

Note that if your Series do not have exact matching index, the resulting DataFrame will have `NaN`

values:

```
```

## Series represent rows

To combine two Series where each series represents a row:

```
```

Note that if your Series do not have exact matching index, the resulting DataFrame will have `NaN`

values:

```
```

# Combining Series vertically

To combine two Series vertically to form a DataFrame:

```
```

Note that calling `concat(~)`

on two series with the default `axis=0`

results in a Series, and so we need to convert this Series into a DataFrame via the DataFrame constructor.

# Related

*chevron_right*

*chevron_right*