【发布时间】:2021-12-02 02:51:53
【问题描述】:
我有一个如下所示的示例数据框:
894385426F4B81 8932F0978F4B80 89434C3243F4B81 899AD7554F4B80
metric 82.557 227.063 9.193 91.205
但是当我生成一个带有破折号的表格时:
def generate_table(dataframe, max_rows=10):
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))
])
])
app = dash.Dash(__name__)
app.layout = html.Div([
html.H4(children='table name'),
generate_table(output)
])
我看到这个索引名称的表:
index 894385426F4B81 8932F0978F4B80 89434C3243F4B81 899AD7554F4B80
metric 82.557 227.06299999999996 9.193 91.205
我拔头发是为了摆脱index这个名字
对于数据框本身,这是可行的,这意味着我在终端中看到的数据框没有index:
output = output.rename_axis(None, axis=0)
我也试过了:
output = output.rename_axis('', axis=1)
output = output.index.set_names([''])
output.columns.name = None
output.index.name = None
没有任何帮助!
顺便说一句,我需要使用 output = output.reset_index(),否则 plotly dash 不会打印“metric”
【问题讨论】:
标签: python pandas dataframe plotly-dash