Concat
Concatenating pandas objects together with concat():
import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.randn(8, 2))
df
pieces = [df[:3], df[3:4], df[6:]]
pd.concat(pieces)
Join
SQL style merges:
left = pd.DataFrame({'key': ['s1', 's1'], 'lval': [1, 2]})
left
right = pd.DataFrame({'key': ['s1', 's1'], 'rval': [3, 4]})
right
pd.merge(left, right, on='key')
Another example that can be given is:
left = pd.DataFrame({'key': ['s1', 's2'], 'lval': [2, 3]})
left
right = pd.DataFrame({'key': ['s1', 's2'], 'rval': [4, 5]})
right
pd.merge(left, right, on='key')
Append rows to a dataframe
df = pd.DataFrame(np.random.randn(4, 4), columns=['P', 'Q', 'R', 'S'])
df
s = df.iloc[3]
df.append(s, ignore_index=True)