filmov
tv
Combine pandas DataFrames with Same Column Names in Python (Example) | Append with concat() Function
Показать описание
Python code of this video:
import pandas as pd # Load pandas library
data1 = pd.DataFrame({"col1":["y", "x", "y", "x", "y"], # Create first pandas DataFrame
"col2":range(10, 15),
"col3":range(5, 0, - 1)})
print(data1) # Print first pandas DataFrame
data2 = pd.DataFrame({"col1":["a", "b"], # Create second pandas DataFrame
"col2":range(0, 2),
"col3":range(3, 1, - 1)})
print(data2) # Print second pandas DataFrame
ignore_index = True,
sort = False)
print(data_concat) # Print combined DataFrame
Follow me on Social Media:
import pandas as pd # Load pandas library
data1 = pd.DataFrame({"col1":["y", "x", "y", "x", "y"], # Create first pandas DataFrame
"col2":range(10, 15),
"col3":range(5, 0, - 1)})
print(data1) # Print first pandas DataFrame
data2 = pd.DataFrame({"col1":["a", "b"], # Create second pandas DataFrame
"col2":range(0, 2),
"col3":range(3, 1, - 1)})
print(data2) # Print second pandas DataFrame
ignore_index = True,
sort = False)
print(data_concat) # Print combined DataFrame
Follow me on Social Media: