-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
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
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
System info
- ipydatagrid 1.3.2
- jupyterlab 4.2.5
- python 3.12.5
- ipython 8.27.0
Metadata
Metadata
Assignees
Labels
No labels