简体   繁体   中英

Jupyter Print column details as html Ipython

I am running a code and need to print the details in Jupyter notebook with Ipython as HTML.

CSV Complexity dataframe has below values, I need to print the count of this each

Complexity

    Simple
    Complex
    Medium

Code I am using as below, need to know how I can capture the count from from dataframe and print as below.

df = pd.read_csv("name.csv", usecols=['Complexity'])
simp = df['Simple'].value_counts()
med = df['Medium'].value_counts()
comp = df['Complex'].value_counts()
html_code ="""
<html>
  <head>
    <h2>Themes Complexity is as below</h2>
    Simple Themes: {}<br>
    Medium Themes: {}<br>
    Complex Themes: {}<br>
  </head>
</html>""".format(simp,med,comp)

from IPython.display import HTML
HTML(html_code)

I need to print the count of simple themes, medium themes and complex themes.

Please help

Below Worked Thank you

df = pd.read_csv("name.csv", usecols=['Complexity'])
simp = df.Test2.value_counts().Simple
med = df.Test2.value_counts().Medium
comp = df.Test2.value_counts().Complex
html_code ="""
<html>
  <head>
    <h2>Themes Complexity is as below</h2>
    Simple Themes: {}<br>
    Medium Themes: {}<br>
    Complex Themes: {}<br>
  </head>
</html>""".format(simp,med,comp)

from IPython.display import HTML
HTML(html_code)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM