w3resource

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



Follow us on Facebook and Twitter for latest update.