Im trying to write a function that writes multiple lists to a singular csv file and i am able to get the column titles to write, but not any of the data. My data is in lists tha
Try this to store the data in csv file with multiple list of different length. Here I tried to give header same as A and B as list name.
import pandas as pd
A = ['Apple', 'Dog']
B = ['Cat', 'OWL', 'PEACOCK']
dict_1 = {'A': A, 'B': B}
df = pd.DataFrame.from_dict(dict_1, orient='index')
dt = df.transpose()
dt.to_csv('myfile.csv', index=False, header=True, encoding='utf-8')