W3cubDocs

/pandas 0.20

pandas.DataFrame.to_dict

DataFrame.to_dict(orient=’dict’) [source]

Convert DataFrame to dictionary.

Parameters:

orient : str {‘dict’, ‘list’, ‘series’, ‘split’, ‘records’, ‘index’}

Determines the type of the values of the dictionary.

  • dict (default) : dict like {column -> {index -> value}}
  • list : dict like {column -> [values]}
  • series : dict like {column -> Series(values)}
  • split : dict like {index -> [index], columns -> [columns], data -> [values]}
  • records : list like [{column -> value}, … , {column -> value}]
  • index : dict like {index -> {column -> value}}

    New in version 0.17.0.

Abbreviations are allowed. s indicates series and sp indicates split.

Returns:

result : dict like {column -> {index -> value}}

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.20.2/generated/pandas.DataFrame.to_dict.html