Python Forum
Not correct letter in dataframes (if put in png)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not correct letter in dataframes (if put in png)
#1
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")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Merging two DataFrames based on indexes from two other DataFrames lucinda_rigeitti 0 1,746 Jan-16-2020, 08:36 PM
Last Post: lucinda_rigeitti

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020