mwouts / itables

Pandas DataFrames as Interactive DataTables
https://mwouts.github.io/itables/
MIT License
740 stars 55 forks source link

More control over truncation #62

Closed gnilrets closed 2 years ago

gnilrets commented 2 years ago

I found some really bizarre truncation behavior and I'm struggling with how to overcome it. Here's the simplest reproducible example I could find:

import pandas as pd
import itables
import itables.options
itables.options.classes = [
    'display', 
    'compact',
    'nowrap'
]

df = pd.DataFrame({
    'origin': [
        'coreB_corsairApuCyclic',
    ],
    'signal_name': [
        'cyc_fuelCtrl_fuelIntegral'
    ],
    'signal_value': [
        277.836
    ]
})

itables.show(df,
    scrollX="500px",
    scrollY="500px", 
    scrollCollapse=True,
    paging=False,  
)

The signal_name is being truncated:

image

If I change the last lower-case l to an upper-case L, it doesn't truncate the string! Other than manually changing the width of the columns, is there any more way to tune how things get truncated?

Another really nice to have would be to be able to hover over a truncated value and see the whole thing.

mwouts commented 2 years ago

Hello @gnilrets , I am wondering if we could not just delete the current fixed width at 70 pixels. Could you please try the following?

import itables.options as opt

del opt.columnDefs

and tell us whether the behavior without the fixed width correspond to what you're looking for?

NB: you could also edit your itables/options.py file and remove columnsDefs there, like in this PR.

Another really nice to have would be to be able to hover over a truncated value and see the whole thing.

I think we're not ready at the moment for this, but nevertheless I see this blog post on how to achieve this in a HTML document (we cannot do that in a notebook at the moment because this would involve injecting JS code after the table).

gnilrets commented 2 years ago

import itables.options as opt

del opt.columnDefs

Nope, that doesn't change the behavior.

mwouts commented 2 years ago

Locally this is what I get with the upcoming version 0.4.6:

image

I'll ship the new version soon, please test it and reopen if you still have an issue with the column width.