Skip to content

Column types get obliterated by Query.jl #313

@samuela

Description

@samuela

I have a DataFrame df with correct column types (String, Float64, etc). However after processing with Query.jl I'm getting only Any column types. Here's the suspect code snippet:

brand_code_df =
    df |>
    @groupby((_.Brand, _.Product_Code)) |>
    @map({
        Brand = key(_)[1],
        Product_Code = key(_)[2],
        WAP = sum(_.Unit_Price .* _.Units) / sum(_.Units),
        WAC = sum(_.Unit_Cost .* _.Units) / sum(_.Units),
        total_sales = sum(_.Sales),
        gross_margin = sum(_.Margin),
        GMP = sum(_.Margin) / sum(_.Sales) * 100,
        total_code_units = sum(_.Units),
        weight = sum(_.Units) / brand_total_units[key(_)[1]],
        unique_prices = unique_prices(_),
    }) |>
    DataFrame

Now, brand_code_df will have only Any column types.

OTOH I've found that doing ... |> collect |> DataFrame does in fact retain the correct column types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions