Programmatically convert pandas dataframe to markdown table

后端 未结 13 1173
梦毁少年i
梦毁少年i 2020-12-13 03:44

I have a Pandas Dataframe generated from a database, which has data with mixed encodings. For example:

+----+-------------------------+----------+-----------         


        
13条回答
  •  有刺的猬
    2020-12-13 04:36

    sqlite3 returns Unicodes by default for TEXT fields. Everything was set up to work before you introduced the table() function from an external source (that you did not provide in your question).

    The table() function has str() calls which do not provide an encoding, so ASCII is used to protect you.

    You need to re-write table() not to do this, especially as you've got Unicode objects. You may have some success by simply replacing str() with unicode()

提交回复
热议问题