Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. html = df.style
  2. .set_properties(**{'width': 200, 'background-color': '#eae2d5',
  3. 'color': 'black', 'font-size': '14px',
  4. 'text-align': 'left'},
  5. subset=['var1'])
  6. .set_properties(**{'color': '33[1m'}, # BOLDING rows 1
  7. subset=['var1'][0]) # Here is the error. .
  8. .set_properties(**{'color': '33[1m'}, # BOLDING rows 7
  9. subset=['var1'][7]) # Here is the error.
  10. .set_properties(**{'width': 80, 'background-color': '#eae2d5',
  11. 'color': 'black', 'font-size': '14px',
  12. 'text-align': 'center'},
  13. subset=['var3', 'var4'])
  14. .set_table_styles([{'selector': 'thead',
  15. 'props': [('background-color', '#b2361e'),
  16. ('color', 'white'),
  17. ('font-size', '18px')]}, ])
  18. .highlight_null(null_color='white').hide_index().render()
  19.  
  20. import pandas as pd
  21. ej = [1,2,3,4,5,3,3,4,2,3,4,23,56]
  22. df = pd.DataFrame(dict(var1=ej, var2=ej, var3=ej, var4=ej))
  23.  
  24. html = (df.style
  25. .set_properties(**{'width': "200px", 'background-color': '#eae2d5',
  26. 'color': 'black', 'font-size': '14px',
  27. 'text-align': 'left'},
  28. subset="var1")
  29. .set_properties(**{'font-weight': "bold"},
  30. subset=(0, 'var1'))
  31. .set_properties(**{'font-weight': 'bold'},
  32. subset=(7, 'var1'))
  33. .set_properties(**{'width': "80px", 'background-color': '#eae2d5',
  34. 'color': 'black', 'font-size': '14px',
  35. 'text-align': 'center'},
  36. subset=['var3','var4'])
  37. .set_table_styles([{'selector': 'thead',
  38. 'props': [('background-color', '#b2361e'),
  39. ('color', 'white'),
  40. ('font-size', '18px')]}, ])
  41. .highlight_null(null_color='white').hide_index().render()
  42. )
  43.  
  44. from IPython.display import HTML
  45. HTML(html)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement