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

Index overlap on multiindex with auto_fit_columns #558

Open
maltomato opened this issue Dec 5, 2024 · 0 comments
Open

Index overlap on multiindex with auto_fit_columns #558

maltomato opened this issue Dec 5, 2024 · 0 comments

Comments

@maltomato
Copy link

Summary

When I create a grid with a multiindex and apply auto_fit_columns the columns overlap. If the error occurs depends on the values. Some index value combinations lead to the issue and others do not.

To reproduce

This version creates the error:

import ipydatagrid
import numpy as np
import pandas as pd

arrays = [
    [1, 1, 1],
    [2, 2.5, 2.5],
    [999, 999, 999],
    [1000, 1000, 1000],
]
index = pd.MultiIndex.from_arrays(arrays, names=('first', 'second', 'third', 'fourth'))
columns = ['A', 'B', 'C', 'D']
df = pd.DataFrame(np.random.randn(3, 4), index=index, columns=columns)

grid = ipydatagrid.DataGrid(df, auto_fit_columns=True)
grid

image

With a slight change in the index values (changing the third 2.5 on index level 2) and it looks normal again.

import ipydatagrid
import numpy as np
import pandas as pd

arrays = [
    [1, 1, 1],
    [2, 2.5, 2],
    [999, 999, 999],
    [1000, 1000, 1000],
]
index = pd.MultiIndex.from_arrays(arrays, names=('first', 'second', 'third', 'fourth'))
columns = ['A', 'B', 'C', 'D']
df = pd.DataFrame(np.random.randn(3, 4), index=index, columns=columns)

grid = ipydatagrid.DataGrid(df, auto_fit_columns=True)
grid

image

System info

  • ipydatagrid 1.3.2
  • jupyterlab 4.2.5
  • python 3.12.5
  • ipython 8.27.0
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

1 participant