Created
August 29, 2014 20:44
-
-
Save worldofchris/6644a0507e13827f53f7 to your computer and use it in GitHub Desktop.
Join two Pandas DataFrames together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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