Skip to content

Instantly share code, notes, and snippets.

@worldofchris
Created August 29, 2014 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save worldofchris/6644a0507e13827f53f7 to your computer and use it in GitHub Desktop.
Save worldofchris/6644a0507e13827f53f7 to your computer and use it in GitHub Desktop.
Join two Pandas DataFrames together
"""
Join two DataFrames together
"""
import pandas as pd
hist_1 = [
{'bucket': '0-1', 'develop': 0},
{'bucket': '2-4', 'develop': 1}
]
df1 = pd.DataFrame(hist_1).set_index('bucket')
hist_2 = [
{'bucket': '0-1', 'approve': 0},
{'bucket': '2-4', 'approve': 2},
{'bucket': '5-6', 'approve': 1}
]
df2 = pd.DataFrame(hist_2).set_index('bucket')
df3 = df1.join(df2, how='outer')
print df3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment