pandas.DataFrame.to_dict

pandas 3.1.1 · DataFrame · method

Convert values to a Python mapping. DataFrame orient controls the shape of that mapping.

Call syntax

DataFrame.to_dict(orient='dict', *, into=<class 'dict'>, index=True)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
orient Optional
Positional or keyword
Default 'dict'
str {'dict', 'list', 'series', 'split', 'tight', 'records', 'index'}

Choose how row labels, columns, and values are arranged in the serialized result.

into Optional
Keyword only
Default <class 'dict'>
class
index Optional
Keyword only
Default True
bool

Supply row labels or control how existing row labels are used.

Returns

dict, list or collections.abc.MutableMapping