Pandas DataFrame: to_records() function
DataFrame - to_records() function
The to_records() function is used to convert DataFrame to a NumPy record array.
Index will be included as the first field of the record array if requested.
Syntax:
DataFrame.to_records(self, index=True, convert_datetime64=None, column_dtypes=None, index_dtypes=None)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
index | Include index in resulting record array, stored in ‘index’ field or using the index label, if set. | bool Default Value: True |
Required |
column_dtypes | If a string or type, the data type to store all columns. If a dictionary, a mapping of column names and indices (zero-indexed) to specific data types. | str, type, dict Default Value: None |
Required |
index_dtypes | If a string or type, the data type to store all index levels. If a dictionary, a mapping of index level names and indices (zero-indexed) to specific data types. This mapping is applied only if index=True. |
str, type, dict Default Value: None |
Required |
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame - to_stata() function
Next: DataFrame - to_string() 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