Back to problems

Convert Dictionary to DataFrame

Algorithm · Walmart Labs · Medium

Write a Python function that uses pandas to convert a nested dictionary into a wide DataFrame. The dictionary maps each desired column name to a list of two-element entries [row_id, value]. Treat row_id as the row label and value as the cell content for that column. Align all entries that share the same row_id, producing one row per distinct row_id and one column per dictionary key. Set the index name to row_id and sort the rows in ascending order by that index. If a row_id…

Checking your access…