beth76
beth76

Reputation: 11

list not getting written in csv using df.to_csv

My dataframe looks like this:

df_dict = {'Title': titles, 'Relase': release, 'Audience Rating': audience_rating,
       'Runtime': runtime, 'Genre': genre, 
       'Votes': votes,  'Director': directors,
       'Actors': actors}
df = pd.DataFrame(df_dict)

This is the Output:

Title   Relase  Audience Rating Runtime Genre   Votes   Director    Actors
0   Sandhippoma (1998)  Not Rated   136 min "
Drama, Romance            " 56  Indrakumar  ['Ambika', 'Sarath Babu', 
'Prakash Raj', 'Radhika Sarathkumar']

1   Joker   (2016)  Not Rated   130 min "
Comedy, Drama            "  2,712   Raju Murugan    ['Raju Saravanan', 'Guru 
Somasundaram', 'Ramya Pandiyan', 'Gayathri']

when doing a df.to_csv only list 'genre' is getting updated as empty. All others are getting written into the csv except 'genre' column

df.to_csv('movies.csv', index=False)

the list 'genre' looks like this:

['\nDrama, Romance            ',
 '\nComedy, Drama            ',
 '\nAction, Biography, Drama            ',]

Upvotes: 1

Views: 39

Answers (0)

Related Questions