ipydatagrid icon indicating copy to clipboard operation
ipydatagrid copied to clipboard

Can't filter rows with NaN values

Open rtaycher opened this issue 2 years ago • 3 comments

Describe the bug I'm guessing it's because of nan equality issues. When I try to filter by column value and select Nan all rows disappear

PS if you know a way to filter rows without Nan that would also be helpful

rtaycher avatar Aug 31 '23 20:08 rtaycher

I'm having the same problem, to give a little more detail:

import numpy as np
df = pd.DataFrame(
    {
        "a":[np.nan, "adf", "c"], "b": [np.nan, "b", np.nan]})

gr = DataGrid(df)
gr

grid-nan-filter-broken

same behaviour when applying the transform directly, i.e.

gr.transform(
    [
        {
            "type": "filter",
            "operator": "empty",
            "columnIndex": 1,
        },
    ]
)

@rtaycher - you can reset the data, i.e.

gr.data = gr.data.dropna(how="all")

its not quite the same though, for my use case this isn't a workable solution.

jgunstone avatar Feb 02 '24 12:02 jgunstone

df = pd.DataFrame(
    {"a":[np.nan, "adf", "c"], "b": [np.nan, "b", np.nan]}
)
text_renderer = TextRenderer(text_value=VegaExpr(""" if(isValid(cell.value), cell.value, ' ') """))
display(DataGrid(df, layout={"height": "100px"}))
display(DataGrid(df, default_renderer=text_renderer, layout={"height": "100px"}))

image

TermeHansen avatar Feb 29 '24 22:02 TermeHansen

hi @TermeHansen - this is good for appearance.. but doesn't help with filtering...

jgunstone avatar Mar 01 '24 10:03 jgunstone