Skip to content

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

@pstaabp

Description

@pstaabp

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.

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