dict_to_dataframe¶
- pyhelpers.ops.dict_to_dataframe(input_dict, k='key', v='value')[source]¶
Convert a dictionary to a dataframe.
- Parameters:
input_dict (dict) – Dictionary to be converted to a dataframe.
k (str) – Column name for keys; defaults to
'key'
.v (str) – Column name for values; defaults to
'value'
.
- Returns:
Dataframe converted from the input dictionary.
- Return type:
pandas.DataFrame
Examples:
>>> from pyhelpers.ops import dict_to_dataframe >>> test_dict = {'a': 1, 'b': 2} >>> dat = dict_to_dataframe(input_dict=test_dict) >>> dat key value 0 a 1 1 b 2