How to Combine Two Series into a Dataframe in Pandas?

Spread the love

Problem –

You have two pandas series and you want to create a dataframe from it.

Solution –

To combine two series into a Dataframe in pandas, you can use the concat method.

import pandas as pd

s1 = pd.Series([1, 2, 3, 4, 5], name='s1')
s2 = pd.Series([6, 7, 8, 9, 10], name='s2')

df = pd.concat([s1, s2], axis=1)
df

Related Posts –

  1. Pandas – pd.concat() – How to concat dataframes in pandas?

Rating: 1 out of 5.

Leave a Reply