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

Set values to missing #38

Closed
ymer opened this issue Aug 31, 2023 · 4 comments
Closed

Set values to missing #38

ymer opened this issue Aug 31, 2023 · 4 comments

Comments

@ymer
Copy link

ymer commented Aug 31, 2023

In standard Julia, I can set a column to missing in this way:
df.year .= missing

In Tidyverse I can set a column to missing like this:
mutate(df, year = NA)

The Tidier equivalent would be:
@mutate(df, year = missing)

However, this does not work.

@kdpsingh
Copy link
Member

Thanks for catching this issue. This is totally fixable.

The issue is that TidierData.jl thinks you are referring to a column named missing instead of the value of missing.

For now, you can use !! to indicate that you're referring to the value rather than the column name.

This should work, but I haven't tested it.

@mutate(df, year = !!missing)

However, for common keywords like missing, true, and false, we will fix this in TidierData.jl so that this workaround isn't needed.

@ymer
Copy link
Author

ymer commented Sep 1, 2023

I have tried
@mutate(df, year = !!missing)
and
@mutate(df, year = [!!missing])

Neither work

@kdpsingh
Copy link
Member

kdpsingh commented Sep 1, 2023

Thanks. We will look and get this fixed.

@kdpsingh
Copy link
Member

This is now fixed in #69. Both of these should now work:

julia> df = DataFrame(a = 1:5)
5×1 DataFrame
 Row │ a     
     │ Int64 
─────┼───────
   11
   22
   33
   44
   55

julia> @chain df @mutate(b = missing, c = !!missing)
5×3 DataFrame
 Row │ a      b        c       
     │ Int64  Missing  Missing 
─────┼─────────────────────────
   11  missing  missing 
   22  missing  missing 
   33  missing  missing 
   44  missing  missing 
   55  missing  missing 

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

No branches or pull requests

2 participants