Skip to content

bug: @egen and @collapse can not summarize over missing values in columns? #190

Open

Description

@gergelyattilakiss

When I use columns that have missing values to calculate something in a groupby it seems to throw error. E.g:
image

On the above df if I run

@with df @egen birt_year = minimum(birth_year), by(person_id)

I get

ERROR: MethodError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer

But if I run

@with df begin
       @mvencode birth_year, mv(99999)
       @egen byear = minimum(birth_year), by(person_id)
end

It throws no error.

Activity

  1. korenmiklos commented on Aug 13, 2024

    @korenmiklos
    Member

    The issue is that all values in a group are missing. So when we do skipmissing, the result will be an empty vector. We may need to special case this. I think we need to return missing in all these cases.

  2. korenmiklos commented on Aug 5, 2026

    @korenmiklos
    Member

    Related: I hit the same root cause from the other side in #233 — mean and sum return NaN and 0.0 on an all-missing group rather than erroring, so the failure is silent there.

    Both look like the same underlying thing: the output column is typed from the non-missing element type (Union{Missing,Float64} in, Float64 out), so missing cannot be represented. Widening the result when the input is missing-typed would let minimum/maximum return missing instead of needing an init, and fix the silent cases at the same time.

  3. added a commit that references this issue on Aug 5, 2026
    908c412
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions