Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #CONCAT1 multiple dfs and add nan value
  2. dfs = [street, city, state, zipcode]
  3. nan_value = 'DROP'
  4. adds_merge = pd.concat(dfs, join='outer', axis=1).fillna(nan_value)
  5. #dropping the mass amount of duplicated columns created by concat above
  6. adds_merge = adds_merge.loc[:,~adds_merge.columns.duplicated()]
  7.  
  8. #CONCAT2
  9. def concat_ordered_columns(frames):
  10. columns_ordered = []
  11. for frame in frames:
  12. columns_ordered.extend(x for x in frame.columns if x not in columns_ordered)
  13. log = pd.concat(frames)
  14. return log[columns_ordered]
  15. data = [search_merge,dl_merge]
  16. elpi_joins = concat_ordered_columns(data)
  17.  
  18. #MERGE
  19. dl_merge = eventcat_dl.merge(elastic_dl, how='inner', left_on=['datetime','type','user'], right_on=['datetime','type','user'])
  20.  
  21. #JOIN
  22. vajoin = visit_action.merge(visit_in, how='inner', left_on=['idvisitor', 'datetime','idvisit'], right_on=['idvisitor', 'datetime','idvisit'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement