Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas concat series into dataframe

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
Comment

concatenate dataframes

# Stack the DataFrames on top of each other
#survey_sub and survey_sub_last10 are both dataframes
vertical_stack = pd.concat([survey_sub, survey_sub_last10], axis=0)

# Place the DataFrames side by side
horizontal_stack = pd.concat([survey_sub, survey_sub_last10], axis=1)
Comment

concat dataframes

result = pd.concat([df1, df2])
Comment

How to Concatenate Dataframe in python

# Stack the DataFrames on top of each other
vertical_stack = pd.concat([survey_sub, survey_sub_last10], axis=0)

# Place the DataFrames side by side
horizontal_stack = pd.concat([survey_sub, survey_sub_last10], axis=1)
Comment

concat dataframe pandas

# provide list of dataframes 
res = pd.concat([df1, df2])
Comment

concat Series to DF as rows

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

concat series to dataframe

>>> pd.concat([students, pd.DataFrame(marks)], axis=1)
        0     0
0    Alex  0.80
1  Lauren  0.75
Comment

PREVIOUS NEXT
Code Example
Python :: numpy shuffle along axis 
Python :: where are python libraries installed ubuntu 
Python :: how to add colors in python 
Python :: convert date to integer python 
Python :: print list vertically python 
Python :: dice rolling simulator python code 
Python :: python pandas if statement 
Python :: dataframe 
Python :: python update function 
Python :: range parameters python 
Python :: panda 
Python :: what are tuples in python 
Python :: add an index column in range dataframe 
Python :: how to print memory address in python 
Python :: stdin and stdout in python 
Python :: python find if part of list is in list 
Python :: python max with custom function 
Python :: list python 
Python :: How to select element using xpath in python 
Python :: how to duplicate a row in python 
Python :: how to work with django ornm __in 
Python :: how to replace special characters in a string python 
Python :: lstm pytorch documentation 
Python :: Open the .txt file 
Python :: pandas transform vs filter 
Python :: print multiple strings in python 
Python :: Convert .tif images files to .jpeg in python 
Python :: ten minute mail 
Python :: python array spread 
Python :: python range function examples 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =