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 Pandas DataFrame Notebooks from here.

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



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/pandas/dataframe/dataframe-from_dict.php