Created
January 28, 2018 10:55
-
-
Save escuccim/3539f682df7585bde14f2b40049f5cae to your computer and use it in GitHub Desktop.
Code to sync columns for two pandas dataframes
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
# For two dataframes X1 and X2, sync columns in X2 to be same as X1 in same order. | |
missing_cols = set( X1.columns ) - set( X2.columns ) | |
for c in missing_cols: | |
X2[c] = 0 | |
X2 = X2[X1.columns] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment