Data Science/Python
[pandas] Create pandas dataframe from nested dict.
You can simply convert your `dictData` to the DataFrame and then take transpose, to make columns into index and index into columns. Sample code import pandas as pd dictData = { 'id1':{'A': 0.2, 'B':0.3, 'C':0.4}, 'id2':{'A': 0.05, 'B':0.8, 'C':0.1}, 'id3':{'A': 0.15, 'B':0.6, 'C':0.25} } df = pd.DataFrame.from_dict(dictData, orient="index") # df = pd.DataFrame(dictData).T ( same resule ) df df o..
2022. 4. 6. 00:55
최근댓글