dict_to_dataframe

pyhelpers.ops.dict_to_dataframe(input_dict, k='key', v='value')[source]

Convert a dictionary to a data frame.

Parameters:
  • input_dict (dict) – a dictionary to be converted to a data frame

  • k (str) – column name for keys

  • v (str) – column name for values

Returns:

a data frame converted from the input_dict

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