Gmousse/dataframe-js

df.filter - possibility to filter not null values

Closed this issue · 2 comments

udos commented

I have data in which some rows are null

example:
df = new DataFrame([ {periodtype: "week", period: null, area: "DE", block: null, source: null}, {periodtype: "week", period: "front", area: "DE", block: "BS", source: "BEST"} ])

while it is possible to filter null values:
df.filter({"period": null})
it is not possible to filter not null values:
df.filter({"period": !null})

is it possible to filter not null?
note: it would be very convenient to be able to filter by not null or by has value . doing this the other way requires much more code. I would have to iterate over all periods and then join the results in a new data frame...

Hi @udos

Indeed it's not possible for now to use the "not" operator by filtering with a payload (object / dictionnary).
However you can did it with the functional api (https://gmousse.gitbooks.io/dataframe-js/doc/api/dataframe.html#filter):

df.filter(row => row.get("period") !== null)

Tell me if it's ok.

udos commented

I missed this possibility :| works like a charm! thank you very much!