Back

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

I want to convert the panda's data frame to the CSV file. This is the code I am using:

df.to_csv('out.csv')

I am getting the error:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u03b1' in position 20: ordinal not in range(128)

Is there a way to provide a tab space between the variables?

1 Answer

0 votes
by (36.8k points)

To give tab space you can use the command below:

df.to_csv(file_name, sep='\t')

To use a specific encoding (e.g. 'utf-8') use the command below:

df.to_csv(file_name, sep='\t', encoding='utf-8')

If you want to know more about the Data Science then do check out the following Data Science which will help you in understanding Data Science from scratch

 

Related questions

Browse Categories

...