Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas append dataframes with same columns

# import module
import pandas as pd
  
# assign dataframes
data1 = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]],
                     columns=['A', 'B', 'C'])
  
data2 = pd.DataFrame([[3, 4], [5, 6]],
                     columns=['A', 'C'])
  
# display dataframes
print('Dataframes:')
display(data1)
display(data2)
  
# merge two data frames
print('After merging:')
pd.concat([data1, data2], axis=0)
Comment

PREVIOUS NEXT
Code Example
Python :: json.dump 
Python :: python formatting string 
Python :: django rest framework viewset 
Python :: python http server 
Python :: list input python 
Python :: python boolean 
Python :: how to plot using pyplot 
Python :: python set union 
Python :: python how to put int into list 
Python :: convert spark dataframe to pandas 
Python :: runserver coomand in django 
Python :: float and int difference 
Python :: python ValueError: zero-size array to reduction operation maximum which has no identity 
Python :: python dunder methods 
Python :: how to store a return value in a variable in python 
Python :: pythpn data tyoe 
Python :: Python How To Convert Text to Speech 
Python :: what are arrays in python 
Python :: change value of column in pandas 
Python :: combination in python math 
Python :: round down py 
Python :: python self usage 
Python :: how to if in pythob 
Python :: what is gui in python 
Python :: how to reduce the image files size in python 
Python :: grab the first letter of each string in an array python 
Python :: python frozenset 
Python :: 2)Write a function that checks whether a number is in a given range (inclusive of high and low) python 
Python :: python mad libs 
Python :: how to add to end of linked list python 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =