Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes unnest_wider bug w missing key #143

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

drizk1
Copy link
Member

@drizk1 drizk1 commented Feb 18, 2025

address #142 found here

julia> a1=Dict("a"=>1, "b"=>Dict("c"=>1, "d"=>2)); a2=Dict("a"=>1, "b"=>Dict("c"=>1)); a=[a1;a2]; df=DataFrame(a);

julia> @unnest_wider(df, b)
2×3 DataFrame
 Row │ a      c      d       
     │ Int64  Int64  Int64?  
─────┼───────────────────────
   1 │     1      1        2
   2 │     1      1  missing 

@drizk1
Copy link
Member Author

drizk1 commented Feb 19, 2025

addresses an edge case in the discourse post

julia> a0=Dict("a"=>0, "b"=>0);  a1=Dict("a"=>1, "b"=>Dict("c"=>1, "d"=>2)); a2=Dict("a"=>2, "b"=>Dict("c"=>2)); a3=Dict("a"=>3, "b"=>Dict("c"=>3));

julia> a=[a0;a1;a2;a3];

julia> df3=DataFrame(a)
4×2 DataFrame
 Row │ b                     a     
     │ Any                   Int64 
─────┼─────────────────────────────
   1 │ 0                         0
   2 │ Dict("c"=>1, "d"=>2)      1
   3 │ Dict("c"=>2)              2
   4 │ Dict("c"=>3)              3

julia> @unnest_wider(df3, b)
4×3 DataFrame
 Row │ a      c        d       
     │ Int64  Int64?   Int64?  
─────┼─────────────────────────
   1 │     0  missing  missing 
   2 │     1        1        2
   3 │     2        2  missing 
   4 │     3        3  missing 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant