python - Encode a dataframe after in import in sql -
i have imported table pandas read_frame
.
my dataframe
has special characters é , à , on. when want display have strange characters.
i wold know can encode html output :
import pandas import pandas.io.sql ipython.display import html df = pandas.io.sql.read_frame('a valid sql query') html(df.to_html())
i need use html output display columns ( have 90 columns) , encoding works, 'cp1252'
, when import in csv
post edited :
i wanted edit post image need 10 reputation ... in fact didn't put enconding in connection . possible sql.read_frame ? used pyodbc :
import pyodbc cnxn = pyodbc.connect('driver={teradata};dbcname=prd;uid=***;pwd=***;quietmode=yes;') df = pandas.io.sql.read_frame("""select * *""", cnxn )
try adding connection creation next thing:
cnxn = pyodbc.connect('driver={teradata};dbcname=prd;uid=*;pwd=*;quietmode=yes;', unicode_results=true)
that should make sure strings returned connections unicode. rest handled pandas , ipython notebook.
Comments
Post a Comment