How to filter out missings (using DataFramesMeta @where)

How do I filter out missings when working with DataFramesMeta? For context, my background is R/Python, and in R I use the tidyverse/dplyr/etc. heavily.

I want to do:

@linq indeed_dice_data |>
    transform(mean_subdomain_all_freq_sma = mean(skipmissing([:subdomain_all_freq_sma, :subdomain_all_freq_sma_1]))) |>
    where(!ismissing.(:mean_subdomain_all_freq_sma)) |>
    select(:subdomain, :floor_month_date, :mean_subdomain_all_freq_sma)

But that doesn’t work… In R/dplyr it’d just be a filter(!is.na(blah_blah_blah)), so I’m curious how to do this simple operation in Julia. Still trying to figure out how to map everything I do in R to Julia, and I’m aware this is probably an uber easy question for most of you.

Thanks in advance!

What’s the error you’re running into? It might just be a typo or something.

Use dropmissing function:

julia> df = DataFrame(a=[1, missing, 2], b=1:3)
3×2 DataFrame
│ Row │ a       │ b     │
│     │ Int64⍰  │ Int64 │
├─────┼─────────┼───────┤
│ 1   │ 1       │ 1     │
│ 2   │ missing │ 2     │
│ 3   │ 2       │ 3     │

julia> @linq df |> transform(d=2*:a) |> dropmissing(:a) |> select(:d, :b)
2×2 DataFrame
│ Row │ d      │ b     │
│     │ Int64⍰ │ Int64 │
├─────┼────────┼───────┤
│ 1   │ 2      │ 1     │
│ 2   │ 4      │ 3     │
1 Like