Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table show incorrect #452

Open
zenz opened this issue May 29, 2024 · 2 comments
Open

Table show incorrect #452

zenz opened this issue May 29, 2024 · 2 comments

Comments

@zenz
Copy link

zenz commented May 29, 2024

If drawing multiple tables in a for loop. the arrangement for first two tables will be conflict.

import mercury as mr  # for widgets
import pandas as pd

app = mr.App(title="Test", description="Table test")

category = ["model1", "model2", "model3", "model4"]

employee = ["employeeA", "employeeB", "employeeC"]
for emp in employee:
    temp_df = pd.DataFrame(
        columns=["类别", "对比年总销售额", "对比年同期销售额", "今年同期销售额", "同期增长额", "同期增长比例%"]
    )
    for x in category:
        temp_df.loc[len(temp_df)] = [
            x,
            1,
            1,
            1,
            1,
            1,
        ]
    mr.Table(data=temp_df, width="800px", text_align="center")

Please see pictures below
截屏2024-05-29 16 16 56

@canasdiaz
Copy link

Same here, I'm using 2.4.3

When I print two tables, I get extra columns I did not expect. I've created different notebooks instead. Any other workaround?

Thank you!

@canasdiaz
Copy link

@zenz The workaround is to print them in different cells. For your example, you will have to create a structure to store the data frames, so they can be printed in different notebook cells.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants