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
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://www.w3resource.com/pandas/dataframe/dataframe-to_records.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics