Skip to content

Allow 'mask' dataframes and vectors into where clause #210

@v0dro

Description

@v0dro

This issue is complimentary to #209 .

The where= clause will only accept BoolArray as the first argument. However, it should also be able to accept dataframes that contain vector names similar to that of the calling dataframe and make the assignment only where there's a true against an index. Something like a 'mask' dataframe.

For example, consider this dataframe:

df  = Daru::DataFrame.new({
  a: [1,2,3,4,5],
  b: [400,500,200,1,5]
})

df_mask = Daru::DataFrame.new({
  a: [true, false, false, true, false],
  b: [false, false true, true, false]
})

The following syntax:

df.where(df_mask) = -1000

...should yield the following dataframe:

Daru::DataFrame.new({
  a: [-1000,2,3,-1000,5],
  b: [400,500,-1000,-1000,5]
})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions