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
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook