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

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

Open
v0dro opened this issue Aug 5, 2016 · 1 comment
Open

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

v0dro opened this issue Aug 5, 2016 · 1 comment

Comments

@v0dro
Copy link
Member

v0dro commented Aug 5, 2016

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]
})
@Shekharrajak
Copy link
Member

I didn't understand this syntax df.where(df_mask) = -1000

I think df.where(df_mask) must return :

Daru::DataFrame.new({
  a: [1,NaN,NaN,4,NaN],
  b: [NaN,NaN,200,1,NaN]
})

And then we must have some method to replace NaN with -1000, isn't it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants