Python Forum
Not correct letter in dataframes (if put in png) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Not correct letter in dataframes (if put in png) (/thread-26084.html)



Not correct letter in dataframes (if put in png) - picnic - Apr-20-2020

I work in Jupiter.When I put pandas dataframe into html and then into png I have some letter (cyrrilic) printed not correct (unreadable symbol). What to do?


import pandas as pd
import matplotlib.pyplot as plt
import imgkit
import seaborn as sns
from IPython.display import HTML
df = pd.DataFrame({'Страна': ['Kazakhstan', 'Россия', 'Belarus', 'Украина'],
'population': [17.04, 143.5, 9.5, 45.5],
'square': [2724902, 17125191, 207600, 603628] })

#Styles
th_props = [
  ('font-size', '13px'),
  ('width','100px'),
  ('text-align', 'center'),
  ('font-weight', 'bold'),
  ('color', '#000000'),
  ('background-color', '#AFEEEE'),('font-family', 'Courier'),

  ('border','2px')
]
# Set CSS properties for td elements in dataframe  
td_props = [  ('font-size', '13px'), ('text-align', 'center')]
# Set table styles
styles = [
  dict(selector="th", props=th_props),
  dict(selector="td", props=td_props)
  ]

#table
df_styled = df.copy()
df_styled = df.style.set_table_styles(styles)
df_styled
html = df_styled.render()
imgkit.from_string(html,'styled_df.png')
Image("styled_df.png")