queryverse / queryverse/Query.jl

Using @mutate with a Dictionary or array loses the column types

Open
#324 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
403
Forks
48
Avg merge
3d 6h
Merged PRs (30d)
6

Description

If one defines:

d=Dict(1=>"xx",2=>"yy",3=>"zz")
df = DataFrame(str=["a","b","c"],x=[1,2,3])

and then

df |> @mutate(y=d[_.x]) |> DataFrame

results in

Row │ str  x    y
     │ Any  Any  Any
─────┼───────────────
   1 │ a    1    xx
   2 │ b    2    yy
   3 │ c    3    zz

losing the types of all of the columns. And doing a little digging, this doesn't seem to be an issue with the dictionary. If instead

d=["xx","yy","zz"]

the above code loses the column types. In addition, if

d2=[7,8,9]

then

df |> @mutate(z=d2[_.x]) |> DataFrame

also loses the column types.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducer in the issue, focusing on the @mutate pipeline and its conversion to DataFrame. Trace why indexing with a dictionary or array changes every column to Any; done means the resulting DataFrame preserves the original column types while adding the derived column.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.