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

concat dataframe pandas

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

concat Series to DataFrame 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 :: how many data types are specified to numeric values in python 
Python :: datetime current year 
Python :: python beep 
Python :: python stack class 
Python :: ursina code 
Python :: load csv file using pandas 
Python :: pandas replace empty strings with NaN 
Python :: restart computer py 
Python :: discord bot python on reaction 
Python :: how to reverse a number in python 
Python :: variance calculation python manually 
Python :: access dataframe column with space 
Python :: list to tensor 
Python :: django check if user is staff in template 
Python :: python custom array sort 
Python :: python string to xml 
Python :: python mod inverse 
Python :: regex all words longer than n 
Python :: pythonic 
Python :: numpy add axis 
Python :: how to reset a variable in python 
Python :: web scraping linkedin profiles python jupyter 
Python :: python code to wait 
Python :: python split dict into chunks 
Python :: how to split a string in python with multiple delimiters 
Python :: messages django 
Python :: pandas describe get mean min max 
Python :: is alphabet python 
Python :: count plot 
Python :: pandas drop columns by index 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =