Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mylist = [{"a": 1, "b": {"c": 2, "d":3}}, {"a": 3, "b": {"c": 4, "d":3}}]
- import pandas as pd
- result_dataframe = pd.DataFrame(mylist)
- print(result_dataframe)
- a b
- 0 1 {'c': 2, 'd': 3}
- 1 3 {'c': 4, 'd': 3}
- new_dataframe = result_dataframe.drop(columns=["b"])
- b_dict_list = [document["b"] for document in mylist]
- b_df = pd.DataFrame(b_dict_list)
- frames = [new_dataframe, b_df]
- total_frame = pd.concat(frames, axis=1)
- a c d
- 0 1 2 3
- 1 3 4 3
Add Comment
Please, Sign In to add comment