Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. from itertools import chain
  2.  
  3. lists = [file1999, file2000, file2001, file2002, file2003]
  4. names = sorted(set(chain.from_iterable(lists)))
  5. new_lists = {col:[name if name in subl else pd.np.nan for name in names] for col, subl in zip(Headers, lists)}
  6.  
  7. df = pd.DataFrame(new_lists)
  8. print(df)
  9.  
  10. 1999 2000 2001 2002 2003
  11. 0 Factory_A Factory_A NaN Factory_A Factory_A
  12. 1 NaN Factory_B Factory_B NaN Factory_B
  13. 2 NaN NaN NaN Factory_C Factory_C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement