sasoptpy.dict_to_frame¶
-
dict_to_frame
(dictobj, cols=None)[source]¶ Converts dictionaries to DataFrame objects for pretty printing
- Parameters
- dictobjdict
Dictionary to be converted
- colslist, optional
Column names
- Returns
- frobjDataFrame
DataFrame representation of the dictionary
Examples
>>> d = {'coal': {'period1': 1, 'period2': 5, 'period3': 7}, >>> 'steel': {'period1': 8, 'period2': 4, 'period3': 3}, >>> 'copper': {'period1': 5, 'period2': 7, 'period3': 9}} >>> df = so.dict_to_frame(d) >>> print(df) period1 period2 period3 coal 1 5 7 copper 5 7 9 steel 8 4 3