Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am trying to export the data like this

['sure', '2']: 169

['2', 'trash']: 1

['what', '2077']: 8

['us', '1']: 75

['1']: 61

['7']: 9

['7', 'years']: 9

['great']: 56

['2']: 39

['hi']: 69

['game', '5']: 1

['experience', '1010']: 1

['100%']: 10

['5']: 12

['5', 'hours']: 2

['game', '1010']: 7

['1010']: 40

['4']: 30

['90%']: 5

['exist', '7']: 1

... created by

my_list = sorted(df, reverse=True)

d = []

c = []

for i,l in enumerate(d):

    if c[i] == 1:

        d.pop(i)

        c.pop(i)

for i,l in enumerate(d):

    print(f"{d[i]}: {c[i]}")

I would like to export the excel file (or csv). Could you please tell me where I should include the to_excel (to_csv) in order to print my lists (d[i]) and their frequencies are (c[i])?

1 Answer

0 votes
by (36.8k points)

You can do something like this after your data is generated

file = pd.DataFrame({'lists': d,'frequency':c})

file.to_csv('name')

Want to be a master in Data Science? Enroll in this Data Scientist

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...