1>>> data = {'row_1': [3, 2, 1, 0], 'row_2': ['a', 'b', 'c', 'd']}
2>>> pd.DataFrame.from_dict(data, orient='index')
3 0 1 2 3
4row_1 3 2 1 0
5row_2 a b c d
6
1>>> data = {'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
2>>> pd.DataFrame.from_dict(data)
3 col_1 col_2
40 3 a
51 2 b
62 1 c
73 0 d
8
1>>> df.to_dict('records')
2[{'col1': 1, 'col2': 0.5}, {'col1': 2, 'col2': 0.75}]
3
1#orientstr {‘dict’, ‘list’, ‘series’, ‘split’, ‘records’, ‘index’}
2#Determines the type of the values of the dictionary.
3#‘dict’ (default) : dict like {column -> {index -> value}}
4#‘list’ : dict like {column -> [values]}
5#‘series’ : dict like {column -> Series(values)}
6#‘split’ : dict like {‘index’ -> [index], ‘columns’ -> [columns], ‘data’ -> [values]}
7#‘records’ : list like [{column -> value}, … , {column -> value}]
8#‘index’ : dict like {index -> {column -> value}}
9
10# Example:
11data = pandas.read_csv("data/data_name.csv")
12to_dict = data.to_dict(orient="records")