def generateTagSpeciesTimeTable(tags): rows = [] for tag in tags: row = [html.Td("Tag " + str(tag.number))] times = tag.speciesTimes for value in times: row.append(html.Td(str(value) + " seconds")) rows.append(html.Tr(row)) return html.Table([ html.Thead( html.Tr([html.Th("Tag Number")] + [ html.Th("Species " + (str(col + 1))) for col in range(tags[0].numSpecies) ])), html.Tbody(rows) ])
def generate_table(df, max_rows=100): """Creates an html table for Html.table component Args: df (dataframe) max_rows (int, optional): The size of the table that will be displayed. Defaults to 100. Returns: Html.table format """ return html.Table(children=[ html.Thead(html.Tr([html.Th(col) for col in df.columns])), html.Tbody([ html.Tr([html.Td(df.iloc[i][col]) for col in df.columns]) for i in range(min(len(df), max_rows)) ]), ])
def make_table(df): return html.Table( children=[ html.Thead( style={"display": "block", "marginBottom": 25}, children=[ html.Tr( children=[ html.Th(column_name.replace("_", " ")) for column_name in df.columns ], style={ "display": "grid", "gridTemplateColumns": "repeat(4, 1fr)", "fontWeight": "600", "fontSize": 22, "fontSize": 16, }, ) ], ), html.Tbody( style={"maxHeight": "50vh", "display": "block", "overflow": "scroll", }, children=[ html.Tr( style={ "display": "grid", "gridTemplateColumns": "repeat(4, 1fr)", "border-top": "1px solid white", "padding": "30px 0px", }, children=[ html.Td(value_column, style={ "textAlign": "center"}) for value_column in value ], ) for value in df.values ], ), ], )
def generate_table(dataframe, max_rows=10): """ It generates a html table which is used in choice_based_recommendation.py file to show the top 10 recommended movies to users based on selected choice Args: dataframe: Pandas dataframe containing the details of recommended movies max_rows: Maximum rows to be displayed in the html table Returns: Html table with 10 movies """ return html.Table([ html.Thead( html.Tr([html.Th(col) for col in dataframe.columns]) ), html.Tbody([ html.Tr([ html.Td(dataframe.iloc[i][col]) for col in dataframe.columns ]) for i in range(min(len(dataframe), max_rows)) ]) ])
async def clean_data(c_data): headers = [] for x in c_data.head(): print(c_data[x].name) headers.append(html.Th(c_data[x].name)) table_header = [html.Thead(html.Tr([html.Th(x) for x in headers]))] table_values = [] provinceState = c_data['provinceState'].values countryRegion = c_data['countryRegion'].values lastUpdate = c_data['lastUpdate'].values confirmed = c_data['confirmed'].values deaths = c_data['deaths'].values recovered = c_data['recovered'].values for p, region, l, c, d, r in zip(provinceState, countryRegion, lastUpdate, confirmed, deaths, recovered): # print(html.Tr([html.Td(p), html.Td(region), html.Td(l), html.Td(c), html.Td(d), html.Td(r)])) table_values.append( html.Tr([ html.Td(p), html.Td(region), html.Td(l), html.Td(c), html.Td(d), html.Td(r) ])) table_body = [html.Tbody(table_values)] return dbc.Row([ dbc.Col(html.Div(), width=2), dbc.Col(dbc.Table(table_header + table_body, bordered=True)), dbc.Col(html.Div(), width=2) ])
def generate_table(semestre, carrera, dataframe=df, max_rows=100): if semestre: if semestre != 'all': dataframe = dataframe[(dataframe['Programa'] == carrera) & (dataframe['Grupo'] == semestre)] else: dataframe = dataframe[(dataframe['Programa'] == carrera)] dataframe = dataframe.drop( 'Unnamed: 0', axis=1).iloc[:, [0, 1, 3, 5, 6, 7, 8, 9, 10, 16]] return [ html.Thead(html.Tr([html.Th(col) for col in dataframe.columns])), html.Tbody([ html.Tr([ html.Td(dataframe.iloc[i][col]) for col in dataframe.columns ]) for i in range(min(len(dataframe), max_rows)) ], style={'color': '#414242'}) ]
def generate_table(df, max_rows=10): #print(df.head()) return html.Table(className="responsive-table", children=[ html.Thead( html.Tr(children=[ html.Th(col.title()) for col in df.columns.values ], style={'color': app_colors['text']})), html.Tbody([ html.Tr(children=[html.Td(data) for data in d], style={ 'color': app_colors['text'], 'background-color': app_colors['background'] }) for d in df.values.tolist() ]) ])
def generate_table3(dataframe, max_rows=350): table_header = [ html.Thead(html.Tr([html.Th(col) for col in dataframe.columns])) ] #[html.Th(dataframe.index.name, scope="col")] + rows = [ html.Tr(children=[ html.Td(dataframe.iloc[i][col]) for col in dataframe.columns ]) for i in range(min(len(dataframe), max_rows)) ] # html.Th(dataframe.index[i], scope="row")] + table_body = [html.Tbody(rows)] table = dbc.Table( table_header + table_body, bordered=True, dark=True, hover=True, responsive=True, striped=True, ) return table
def generate_table(df, max_rows=10): return html.Table( className="responsive-table", children=[ html.Thead( html.Tr( children=[ html.Th(col.title()) for col in df.columns.values ], style={"color":app_colors["text"]} ) ), html.Tbody( [html.Tr(children=[ html.Td(data) for data in row ], style={"color":app_colors["text"]} ) for row in df.values.tolist()] ) ] )
def generate_table(dataframe, max_rows=10): """this function generates an html table fomr a dataframe Args: dataframe: a pandas DataFrame max_rows (int, optional): number of rows in table Defaults to 10. Returns: html table """ return html.Table([ html.Thead( html.Tr([html.Th(col) for col in dataframe.columns]) ), html.Tbody([ html.Tr([ html.Td(dataframe.iloc[i][col]) for col in dataframe.columns ]) for i in range(min(len(dataframe), max_rows)) ]) ])
def display_src_tissue(val1): if val1 != None: sourcegenes = list(src_tgt_tissue[str(val1)]['source']) # print(sourcegenes) # sourcegenes = sourcegenes.sort() if (len(sourcegenes) % tablebreak != 0): while (len(sourcegenes) % tablebreak != 0): sourcegenes.append(' ') return html.Table([ html.Thead(html.Tr([html.Th(' ') for i in range(tablebreak)])), html.Tbody([ html.Tr([ html.Td(gene.upper()) for gene in sourcegenes[i * tablebreak:i * tablebreak + tablebreak] ]) for i in range(len(sourcegenes) // tablebreak) ]) ])
def generate_table(max_rows=-1): dataframe = getdata.get_dataframe() return html.Table([ html.Thead( html.Tr([html.Th(col,style={'border': '1px solid white'}) for col in dataframe.columns]), ), html.Tbody([ html.Tr([ html.Td(dataframe.iloc[i][col], style={'border': '1px solid white', 'textAlign':'left', 'marginLeft': '20px'}) for col in dataframe.columns ]) for i in range(len(dataframe)) ], style={'border': '1px solid white'}) ], style={'border': '1px solid white', 'borderCollapse': 'collapse', 'fontFamily': 'sans-serif', 'color':'white', 'width': '60%'})
def generate_table(dataframe, max_rows=50, idT='id_padrao'): data = dataframe.copy() data.columns = [ 'Notificação', 'Hospital', 'Ocupação média', 'Total Óbitos' ] data['Ocupação média'] = data['Ocupação média'].round(2) data = data.sort_values(by=['Notificação', 'Hospital']) for col in data.columns: if data[col].dtype not in ['object', 'int64', 'float64']: data[col] = data[col].dt.strftime('%m-%Y') return html.Table( id=idT, children=[ html.Thead(html.Tr([html.Th(col) for col in data.columns])), html.Tbody([ html.Tr([html.Td(data.iloc[i][col]) for col in data.columns]) for i in range(min(len(data), max_rows)) ]) ])
def Table(report, run_id, columns=None): rows = [] if not columns: columns = report.keys() for i in range(len(report["id"])): row = [] for col in columns: value = report[col][i] if col == 'id': cell = html.Td( html.A(href="/test/" + str(run_id) + "/" + value, children=value)) else: cell = html.Td(children=value) row.append(cell) rows.append(html.Tr(row)) rows = [html.Tbody(rows)] head = html.Thead([html.Tr([html.Th(col) for col in columns])]) return html.Table([head] + rows, className="table table-hover table-bordered table-sm")
def update_metadata_table(value, slider_values): #tdf = DF[['source', 'text_tokens']].sort_values('text_tokens', ascending=False).head(10) min_tokens = slider_values[0] max_tokens = slider_values[1] if slider_values[1] < 5000 else 1000000 tdf = DF[(DF['text_tokens'] >= min_tokens) & (DF['text_tokens'] <= max_tokens)] s = len(tdf) tdf = tdf[value].value_counts().head(10) t = html.Table([ html.Thead( html.Tr([html.Th(value), html.Th('Documents'), html.Th('')]) ), html.Tbody([ html.Tr([ html.Td(i), html.Td(v), html.Td(f'{v/s*100:.2f}%') ]) for i, v in tdf.items() ]) ], style={'width': '100%'}) text = ['Ajuster le slider pour filtrer par nombre de tokens.', html.Br(), f'Min tokens: {min_tokens} | Max tokens: {max_tokens if max_tokens < 10000 else "5000+"} | Total docs: {s}'] return t, text
def create_hours_table(hours: dict): header_values = ['Day:', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] table_header = [html.Thead(html.Tr([html.Th(_) for _ in header_values]))] row = [html.Td('Hours:')] for day in ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']: if day in hours: row.append(html.Td(hours[day].replace(':0', ':00'))) else: row.append(html.Td('Closed')) row = html.Tr(row) table = dbc.Table( table_header + [html.Tbody(row)], bordered=True, hover=True, responsive=True, striped=True, ) return table
def generate_sell_list(): global sell_orders return html.Table([ html.Thead( html.Tr([ html.Th('Coin Name'), html.Th('close'), html.Th('volume'), html.Th('등락률(%)') ]) ), html.Tbody([ html.Tr([ html.Td(od["coin_name"]), html.Td(f'{od["price"]}'), html.Td(f'{od["volume"]}'), html.Td(f'{od["chg"]}') ]) for od in sell_orders ]) ])
def create_table(df, do_not_create): return html.Table( className='table table-sm', style={'borderTop': 'none'}, children=[ html.Thead( className='thead-light', children=html.Tr( [ html.Th(column, style={ 'fontSize': 'small', 'textAlign': 'center'}) for column in df.columns if column not in do_not_create ] ) ), html.Tbody( [create_row(row, do_not_create) for index, row in df.iterrows()] ), ] )
def update_asean_table(date_index): global asean_date global asean_datefiltered asean_date = asean_df['date'].unique()[date_index] asean_datefiltered = get_asean_dailydf(date=asean_date, df=asean_df) # Using Bootstrap Table asean_header = [ html.Thead( html.Tr([ html.Th('Rank'), html.Th('Country'), html.Th("Confirmed"), html.Th("Deaths"), html.Th("Recovered"), html.Th('Active Cases'), html.Th('Death Rate'), html.Th('Recovery Rate') ])) ] asean_rows = [ html.Tr([html.Td(html.Small(i)), \ html.Td(html.Small(asean_datefiltered.loc[i]['country'])), \ html.Td(html.Small(locale.format_string("%d", asean_datefiltered.loc[i]['confirmed'], grouping=True))), \ html.Td(html.Small(locale.format_string("%d", asean_datefiltered.loc[i]['deaths'], grouping=True))), \ html.Td(html.Small(locale.format_string("%d", asean_datefiltered.loc[i]['recovered'], grouping=True))), \ html.Td(html.Small(locale.format_string("%d", asean_datefiltered.loc[i]['active'], grouping=True))), \ html.Td(html.Small(asean_datefiltered.loc[i]['death_rate'])), \ html.Td(html.Small(asean_datefiltered.loc[i]['recovery_rate']))]) for i in asean_datefiltered.index ] asean_body = [html.Tbody(children=asean_rows)] asean_table = dbc.Table(asean_header + asean_body, bordered=False) # Change Date Format parsed_aseandate = datetime.strptime(str(asean_date)[:10], "%m/%d/%Y") revised_aseandate = datetime.strftime(parsed_aseandate, "%B %-d, %Y") return [ html.H5(f"ASEAN Daily Standings ({str(revised_aseandate)})"), html. P("Use slider below to see daily changes. The slider affects both the table and the bubble plot.", className="display-7"), asean_table ]
def generate_table(dataframe, max_rows=10000): dataframe = dataframe.sort_index(ascending=False) dataframe = dataframe.reset_index() dataframe["index"] = dataframe["index"].astype(str).str[:10] return html.Table([ html.Thead( html.Tr([ html.Th(col, style=style_callback(col)) for col in dataframe.columns ])), html.Tbody([ html.Tr([ html.Td(dataframe.iloc[i][col], style={'border-right': '2px solid black'} if "%" in col or "Recovery" in col or "index" in col else {}) for col in dataframe.columns ]) for i in range(min(len(dataframe), max_rows)) ]) ], className='table')
def df_to_table(df): return dbc.Table( # Header [html.Thead([html.Tr([html.Th(col) for col in df.columns])])] + # Body [ html.Tbody([ html.Tr( [html.Td(html.A(df.iloc[i][col])) for col in df.columns]) for i in range(len(df)) ]) ], style={ 'backgroundColor': 'white', 'font-size': '10px', 'height': '10px', 'color': 'blue', 'text-align': 'left', 'width': '100%' })
def generate_overview_table(jobs): jobs_summary = jobs[['job_id', 'node']]\ .drop_duplicates()\ .groupby('job_id')\ .count() jobs_summary = jobs_summary.merge(jobs.groupby('job_id')[['time']].min(), on='job_id') jobs_summary = jobs_summary.merge(jobs.groupby('job_id')[['time']].max(), on='job_id') jobs_summary.columns = ['nodes', 'start time', 'end time'] jobs_summary.insert(0, 'job_id', jobs_summary.index) return html.Table([ html.Thead( html.Tr([html.Th(column) for column in jobs_summary.columns])), html.Tbody([ html.Tr([ html.Td(jobs_summary.loc[job_id][column]) for column in jobs_summary.columns ]) for job_id in jobs_summary.index ]) ])
def detailInfo(open, close, is_open, select): print(' is this ever called???') select = changePeriod(select) result = user.closeData(select, choice=False) table_header = [ html.Thead( html.Tr([html.Th(col) for col in list(result.columns)])) ] rows = result.values.tolist() table_row = list() for row in rows: temp = [html.Td(data) for data in row] table_row.extend([html.Tr(temp)]) result = html.Div( dbc.Table(table_header + [html.Tbody(table_row)], bordered=True)) if open or not close: return not is_open, result return is_open, result
def generate_2table(materia, carrera, dataframe=df, max_rows=100): if materia: dataframe = dataframe[(dataframe['Programa'] == carrera) & (dataframe['Unidad de aprendizaje'] == materia)] dataframe = dataframe.drop( 'Unnamed: 0', axis=1).iloc[:, loc_list].rename(columns={ 'Semestre': 'Sem', 'Calificacion': 'Cal' }) return [ html.Thead(html.Tr([html.Th(col) for col in dataframe.columns])), html.Tbody([ html.Tr([ html.Td(dataframe.iloc[i][col]) for col in dataframe.columns ]) for i in range(min(len(dataframe), max_rows)) ], style={'color': '#414242'}) ]
def generate_table(dataframe, max_rows=3): return html.Div(children=[ html.Table([ html.Thead( html.Tr([html.Th(col) for col in dataframe.columns], style={'text-align': 'left'})), html.Tbody([ html.Tr([ html.Td(dataframe.iloc[i][col]) for col in dataframe.columns ], style={'text-align': 'left'}) for i in range(min(len(dataframe), max_rows)) ]) ], style={'width': '1080px'}) ], style={ 'display': 'flex', 'justify-content': 'center', })
def update_table_mordida(n_clicks, a, b, c, d): atable_header = [ html.Thead(html.Tr([html.Th("Coordenada"), html.Th("Valor")])) ] arow1 = html.Tr([ html.Td("Inicio X"), # html.Td(a), dcc.Input(id='input-inicio-x-mordida', value=a), ]) arow2 = html.Tr([ html.Td("Inicio Y"), # html.Td(b) dcc.Input(id='input-inicio-y-mordida', value=b), ]) arow3 = html.Tr([ html.Td("Fin X"), # html.Td(c), dcc.Input(id='input-fin-x-mordida', value=c), ]) arow4 = html.Tr([ html.Td("Fin Y"), # html.Td(d) dcc.Input(id='input-fin-y-mordida', value=d), ]) atable_body = [html.Tbody([arow1, arow2, arow3, arow4])] # im = Image.open("Samsung.png") # width, height = im.size # print('width' + width) # print('height' + height) # print("IMG CARGADA") # borders = (inicio_x, inicio_y, width-fin_x, height-fin_y) # print(borders) # cropped = ImageOps.crop(im, borders) # cropped.save("E:/Miguel Orjuela/PROYECTOS/CES App/S return dbc.Table(atable_header + atable_body, bordered=True)
def generate_table(dataframe, start_row=0, max_rows=20, filter_survey_value="", filter_region_value="", filter_holeid=""): if (filter_survey_value != ""): dataframe = dataframe.loc[dataframe["SURVEY_STATUS"] == filter_survey_value] if (filter_region_value != ""): dataframe = dataframe.loc[dataframe["REGION"].str.contains( filter_region_value, na=False)] if (filter_holeid != ""): dataframe = dataframe.loc[dataframe["HOLEID"].str.contains( filter_holeid, na=False)] if (start_row == "" or start_row < 0): start_row = 0 elif (start_row >= len(dataframe)): start_row = len(dataframe) - 1 last_row = min(len(dataframe), start_row + max_rows) if (dataframe.size > 0): return html.Div([ html.P("Showing rows {} - {} out of {} total.".format( start_row + 1, last_row, len(dataframe))), html.Table([ html.Thead([ html.Tr([html.Th("Row No.")] + [html.Th(col) for col in dataframe.columns]) ]), html.Tbody([ html.Tr([html.Td(i + 1)] + [ html.Td(dataframe.iloc[i][col]) for col in dataframe.columns ]) for i in range(start_row, last_row) if (i < len(dataframe)) ]) ]) ], className="app-text") else: return html.P("No data for this filter combination.")
def df2table(filter_columns, sort_by, n_min, table_type): n_min = 0 if not n_min else n_min if table_type == 'champs': dataframe = df_all_champ accepted_rows = list(dataframe['nom'].values) + ['moyenne'] accepted_cols = dataframe.columns if not filter_columns else filter_columns asc = ['position moyenne', 'mmr total perdu'] ordered_columns = [ 'nom', 'position moyenne', 'winrate', 'mmr moyen par partie', 'gain mmr', 'mmr total gagné', 'mmr total perdu', 'pickrate', 'nombre de pick', '% top 1', '% top 2', '% top 3', '% top 4', '% top 5', '% top 6', '% top 7', '% top 8', 'nombre de fois proposé', '% de parties', '% proposé' ] dataframe = dataframe[ordered_columns] else: dataframe = df_types accepted_rows = list(dataframe['nom'].values) accepted_cols = dataframe.columns asc = ['position moyenne', 'mmr total perdu'] if sort_by != None and sort_by in dataframe.columns: dataframe = dataframe.sort_values( sort_by, ascending=False if sort_by not in asc else True) return html.Table([ html.Thead( html.Tr([ html.Th(col) for col in dataframe.columns if col in accepted_cols ])), html.Tbody([ html.Tr([ html.Td(dataframe.iloc[i][col]) for col in dataframe.columns if col in accepted_cols ]) for i in range(len(dataframe)) if dataframe.iloc[i]['nom'] in accepted_rows and (dataframe.iloc[i]['nombre de pick'] >= n_min or dataframe.iloc[i]['nom'] == 'moyenne') ]) ], className='table')
def generate_table(clickData, feature, max_rows=20): if clickData is None: raise PreventUpdate else: x = clickData['points'][0]['x'] dataframe = df_plot.loc[df_plot[feature] == x] table = html.Table( [ html.Thead( html.Tr([html.Th(col) for col in list(colnames.values())])), html.Tbody([ html.Tr([ html.Td(writeElement(i, col, dataframe)) for col in dataframe.columns ], ) for i in range(min(len(dataframe), max_rows)) ]), ], className='qcsummary', ) # class="table-row" data-href="http://tutorialsplane.com" heading = html.H4('Showing studies where ' + colnames[feature] + ' = ' + x, style={ 'textAlign': 'center', }) # table = dbc.Table.from_dataframe(dataframe, # striped=True, # bordered=True, # hover=True, # responsive=True, # className='qcsummary' # ) return [heading, table]
def makeBootStrapTable(df, verbose_col_names, tableClass='table table-hover'): '''Description: Creates an html table for use in Dash. The function indicates whether a datatype is categorical or numerical, consequently assigning a class to that html component which can be styled by class (e.g. left aligned for categorical and center for numeric)''' # get data types of df: data_types_dict = df.dtypes.to_dict() html_table = [] # create table headers html_row = [] for col in df.columns: if data_types_dict[col] == object: className = 'categoricalTableCell' else: className = 'numericalTableCell' html_row.append(html.Th(verbose_col_names[col], className=className)) html_table.append(html.Thead(html_row)) # create the table cells html_body = [] for index, row in df.iterrows(): html_row = [] for col in df.columns: # look up the data type in the data_types_dict, which will be used to style the table if data_types_dict[col] == object: className = 'categoricalTableCell' else: # assume it is className = 'numericalTableCell' html_row.append(html.Td(row[col], className=className)) html_body.append(html.Tr(html_row)) html_table.append(html.Tbody(html_body)) Dash_table = html.Table(html_table, className=tableClass) return Dash_table