Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import chain
- lists = [file1999, file2000, file2001, file2002, file2003]
- names = sorted(set(chain.from_iterable(lists)))
- new_lists = {col:[name if name in subl else pd.np.nan for name in names] for col, subl in zip(Headers, lists)}
- df = pd.DataFrame(new_lists)
- print(df)
- 1999 2000 2001 2002 2003
- 0 Factory_A Factory_A NaN Factory_A Factory_A
- 1 NaN Factory_B Factory_B NaN Factory_B
- 2 NaN NaN NaN Factory_C Factory_C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement