How to groupby a column and take the mean while ignoring missing values

Hi how’s it going,

I’m trying to do by(df, col1, numeric_col=>mean)

however it’s not working. I tried skipmissing=true but turns out that skips any group that has even 1 missing value. If the values of numeric_col for a group are [1,3,missing,missing] I would like it to return 2 and essentially ignore rows that are missing.

Thanks

by(df, :g, :x=>mean∘skipmissing)

?∘
4 Likes