I am now trying to output a data frame written in Serbian. First I try to use the utf-8 or utf-8-sig codec. There are multiple columns, which is correct. However, the output csv file has the garbled problem. Then I try to output the data frame using utf-16. The codec is correct this time. But the output csv just has one column, like:
My code is:
df1.to_csv('people.csv', encoding = "utf-16",index = False)
The head of the original data frame is:
If I use utf-8, the output is (correct column but incorrect codec):
If I use utf-16, the output is (correct codec but incorrect column):
How can I solve the problem. Thanks!