Answers for "create new dataframe from 2 different series"

2

dataframe from two series

In [1]: s1 = pd.Series([1, 2], index=['A', 'B'], name='s1')

In [2]: s2 = pd.Series([3, 4], index=['A', 'B'], name='s2')

In [3]: pd.concat([s1, s2], axis=1)
Out[3]:
   s1  s2
A   1   3
B   2   4

In [4]: pd.concat([s1, s2], axis=1).reset_index()
Out[4]:
  index  s1  s2
0     A   1   3
1     B   2   4
Posted by: Guest on April-20-2020
0

create dataframe from two variables

pd.DataFrame({'r': r, 's': s})

Out: 
    r   s
0   0   0
1   3   5
2   6  10
3   9  15
4  12  20
Posted by: Guest on January-19-2021

Code answers related to "create new dataframe from 2 different series"

Python Answers by Framework

Browse Popular Code Answers by Language