pandas.DataFrame.to_dict

DataFrame.to_dict(outtype='dict')

Convert DataFrame to dictionary.

Parameters:

outtype : str {‘dict’, ‘list’, ‘series’, ‘records’}

Determines the type of the values of the dictionary. The default dict is a nested dictionary {column -> {index -> value}}. list returns {column -> list(values)}. series returns {column -> Series(values)}. records returns [{columns -> value}]. Abbreviations are allowed.

Returns:

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