0

I have two list in python and i want to convert that in a table and export it as csv file.

    print price
    print name

Output:
    [u'\xa34', u'\xa38', u'\xa312', u'\xa30']
    [u'apple', u'orange', u'mango', u'pineapple']

The final output i want is:

Name         Price
Apple        34
Orange       38
Mango        312
Pineapple    30

I tried using pandas but i am unable to do so. Could someone suggest me some link so that i can study about creating a table and exporting it.

sky_bird
  • 247
  • 1
  • 4
  • 13

1 Answers1

3

Step 1: Initialise the dataframe

df = pd.DataFrame({'Name' : name, 'Price' : price})    

Step 2: Call df.to_csv to export your data to csv format

df.to_csv('items.csv', index=False, encoding='utf-8')
cs95
  • 379,657
  • 97
  • 704
  • 746