I've got two lists.
list1 = ['abc', 'bcd', 'efg', 'ijk', 'lpo']
list2 = [111, 222, 333]
Sometimes list1 is more values than list2, and other times list2 is more values than list1.
How am I able to write on a CSV File Like This.
abc 111
bcd 222
efg 333
ijk
lpo
CodePudding user response:
You can try with itertools
zip_longest
then to_csv
import itertools
pd.DataFrame(itertools.zip_longest(list1,list2)).to_csv('Your.csv',header=None, index=None)