python - Pandas explode dictionary to rows - Stack Overflow
stackoverflow.com › questions › 67336514Apr 30, 2021 · You can use .apply() with pd.Series() to 'explode' the dictionary into columns and then use .melt() to transform the columns into Subject and Marks columns, as follows: (df.drop(columns='Sub_Marks') .join(df.apply(lambda x: pd.Series(x['Sub_Marks']), axis=1)) .melt(id_vars='Name', value_vars=['Maths', 'English', 'Science'], var_name='Subject', value_name='Marks') .sort_values('Name') ).reset_index(drop=True)
python - Pandas explode list of dictionaries into rows ...
https://stackoverflow.com/questions/4714868307.11.2017 · But would like to have the list of dictionary objects exploded into (flattened?) into actual rows like this: a, b, name 0 { 2, 1, this} 1 { 4, 3, this} 0 { 2, 1, that} 1 { 4, 3, that} Having ... How to iterate over rows in a DataFrame in Pandas. 2840. How do I select rows from a DataFrame based on column values?