html - Reformatting column width when using pandas dataframe.to_html() -
i have pandas dataframe want display table in html template. works part, of strings in dataframe being truncated. using to_html()
convert pandas dataframe html friendly table , tried using col_space
argument didn't seem have affect.
the python code:
options = dbi.getdbtables() #returns list of names of available tables table_headers = [] table_name in options: table_name = str(table_name) df = dbi.selectdf("select * %s limit 1" % table_name) #gets actual dataframe each table name header = df.columns.values header = "<br>".join(header) table_headers.append(header) header_dict = dict(zip(options,table_headers)) table_options = pandas.dataframe(header_dict,index=[0]) table_options = table_options.to_html(classes=["table table-hover"],index=false,escape=false,col_space=400) #changing col_space nothing. search_dict = {'table_names':table_options}
the html code:
<div class="table-responsive"> {{ table_names | safe }} </div>
picture of table truncation occurring:
how pandas stop truncating (shown '...' in picture) content?
much appreciated!
just needed set pandas.set_option('display.max_colwidth',100)
Comments
Post a Comment