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

Export buttons with formatted data frame #259

Closed
brentgunderson opened this issue Apr 22, 2024 · 2 comments · Fixed by #264
Closed

Export buttons with formatted data frame #259

brentgunderson opened this issue Apr 22, 2024 · 2 comments · Fixed by #264
Milestone

Comments

@brentgunderson
Copy link

I just started using ITables, what a great package!

Interestingly, when I try to format a data frame, I seem to lose the ability to add export buttons.

Example below (ITables 2.0.0)

import string
 
import numpy as np
import pandas as pd
from itables import init_notebook_mode, show
from itables.sample_dfs import get_countries
 
init_notebook_mode()
 
df = get_countries(html=False)
 
# Add columns for the searchPanes demo
df["climate_zone"] = np.where(
    df["latitude"].abs() < 23.43615,
    "Tropical",
    np.where(
        df["latitude"].abs() < 35,
        "Sub-tropical",
        # Artic circle is 66.563861 but there is no capital there => using 64
        np.where(df["latitude"].abs() < 64, "Temperate", "Frigid"),
    ),
)
df["hemisphere"] = np.where(df["latitude"] > 0, "North", "South")
 
wide_df = pd.DataFrame(
    {
        letter: np.random.normal(size=100)
        for letter in string.ascii_lowercase + string.ascii_uppercase
    }
)
 
show(df, buttons=["copyHtml5", "csvHtml5", "excelHtml5"])
 
show(
    df.style.format({"longitude": "{:,.1f}"}),
    buttons=["pageLength", "copyHtml5", "csvHtml5", "excelHtml5"],
)

image

@joshy
Copy link

joshy commented Apr 24, 2024

I am not sure why pagination is shown instead of buttons but if you configure the location, it will be shown:

show(
    df.style.format({"longitude": "{:,.1f}"}),
    buttons=["pageLength", "copyHtml5", "csvHtml5", "excelHtml5"],
    layout =  {"topStart":"buttons"}
)

@mwouts mwouts added this to the 2.0.1 milestone Apr 24, 2024
@mwouts
Copy link
Owner

mwouts commented Apr 24, 2024

Thank you @brentgunderson for the detailed report, and @joshy for the workaround! I will have a look soon - I would expect itables to set the "buttons" on the layout too but apparently this is not the case here.

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

Successfully merging a pull request may close this issue.

3 participants