python - Encoding error in Pandas DataFrame -


in pandas dataframe, when writing csv can encode file adding argument encoding='utf-8'

however there issue this. if getting data directly database , placing directly dataframe, when writing csv, encoding error:

unicodeencodeerror: 'ascii' codec can't encode characters in position 24-25: ordinal not in range(128) 

so decoding/encoding needs happen prior placing data datframe.

does have simple solution this?

if creating dataframe database, can use read_sql:

df = pd.read_sql('select * foo', con) 

here con connection object, e.g. created using sqlite3 or mysqldb.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -