w3resource

Pandas DataFrame: from_dict() function

DataFrame - from_dict() function

The from_dict() function is used to construct DataFrame from dict of array-like or dicts.

Syntax:

classmethod DataFrame.from_dict(data, orient='columns', dtype=None, columns=None)

Parameters:

Name Description Type/Default Value Required / Optional
data  Of the form {field : array-like} or {field : dict}. dict Required
orient   The “orientation” of the data. If the keys of the passed dict should be the columns of the resulting DataFrame, pass 'columns' (default). Otherwise if the keys should be rows, pass 'index'.  {'columns', 'index'}
Default Value: 'columns'
Required
dtype  Data type to force, otherwise infer. dtype
Default Value: None
Required
columns  Column labels to use when orient='index'. Raises a ValueError if used with orient='columns'. list
Default Value: None
Required

Returns: DataFrame

Example:


Download the above Notebook from here.

Previous: DataFrame - sparse.to_dense() function
Next: DataFrame - info() function