Python | Pandas DataFrame.to_records Last Updated : 21 Feb, 2019 Comments Improve Suggest changes Like Article Like Report Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure of the Pandas. Pandas DataFrame.to_records() function convert DataFrame to a NumPy record array. The index will be included as the first field of the record array if requested. Syntax: DataFrame.to_records(index=True, convert_datetime64=None, column_dtypes=None, index_dtypes=None) Parameter : index : bool, default True convert_datetime64 : Whether to convert the index to datetime.datetime if it is a DatetimeIndex. column_dtypes : If a string or type, the data type to store all columns index_dtypes : If a string or type, the data type to store all index levels Returns : numpy.recarray Example #1: Use DataFrame.to_records() function to convert the given Dataframe to a numpy record array. Python3 # importing pandas as pd import pandas as pd # Creating the DataFrame df = pd.DataFrame({'Weight':[45, 88, 56, 15, 71], 'Name':['Sam', 'Andrea', 'Alex', 'Robin', 'Kia'], 'Age':[14, 25, 55, 8, 21]}) # Create the index index_ = pd.date_range('2010-10-09 08:45', periods = 5, freq ='H') # Set the index df.index = index_ # Print the DataFrame print(df) Output : Now we will use DataFrame.to_records() function to convert the given dataframe to a numpy record array representation. Python3 1== # convert to numpy record array result = df.to_records() # Print the result print(result) Output : As we can see in the output, the DataFrame.to_records() function has successfully converted the given dataframe to a numpy record array representation. Example #2: Use DataFrame.to_records() function to convert the given Dataframe to a numpy record array. Python3 # importing pandas as pd import pandas as pd # Creating the DataFrame df = pd.DataFrame({"A":[12, 4, 5, None, 1], "B":[7, 2, 54, 3, None], "C":[20, 16, 11, 3, 8], "D":[14, 3, None, 2, 6]}) # Create the index index_ = ['Row_1', 'Row_2', 'Row_3', 'Row_4', 'Row_5'] # Set the index df.index = index_ # Print the DataFrame print(df) Output : Now we will use DataFrame.to_records() function to convert the given dataframe to a numpy record array representation. Python3 1== # convert to numpy record array result = df.to_records() # Print the result print(result) Output : As we can see in the output, the DataFrame.to_records() function has successfully converted the given dataframe to a numpy record array representation. Comment More infoAdvertise with us Next Article Python | Pandas DataFrame.to_records S Shubham__Ranjan Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame Pandas-DataFrame-Methods Practice Tags : python Similar Reads Pandas DataFrame.to_string-Python Pandas is a powerful Python library for data manipulation, with DataFrame as its key two-dimensional, labeled data structure. It allows easy formatting and readable display of data. DataFrame.to_string() function in Pandas is specifically designed to render a DataFrame into a console-friendly tabula 5 min read Python | Pandas DataFrame.values Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure o 2 min read Python Pandas Dataframe To Nested Json When working with data in Python,Pandas is a popular library for handling tabular data efficiently. Converting a Pandas DataFrame to a nested JSON structure can be necessary for various reasons, such as preparing data for API responses or interacting with nested JSON-based data structures. In this a 3 min read Python | Pandas DataFrame.blocks Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure o 2 min read Python | Pandas DataFrame.to_latex() method With the help of DataFrame.to_latex() method, We can get the dataframe in the form of latex document which we can open as a separate file by using DataFrame.to_latex() method. Syntax : DataFrame.to_latex() Return : Return the dataframe as a latex document. Example #1 : In this example we can say tha 1 min read Python | Pandas Index.to_frame() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.to_frame() function create a dataFrame from the given index with a column 2 min read Pandas DataFrame.to_sparse() Method Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure o 2 min read How to convert pandas DataFrame into SQL in Python? In this article, we aim to convert the data frame into an SQL database and then try to read the content from the SQL database using SQL queries or through a table. Convert Pandas DataFrame into SQL in PythonBelow are some steps by which we can export Python dataframe to SQL file in Python: Step 1: I 4 min read How to write Pandas DataFrame as TSV using Python? In this article, we will discuss how to write pandas dataframe as TSV using Python. Let's start by creating a data frame. It can be done by importing an existing file, but for simplicity, we will create our own. Python3 # importing the module import pandas as pd # creating some sample data sample = 1 min read How to Reverse Row in Pandas DataFrame? In this article, we will learn how to reverse a row in a pandas data frame using Python. With the help of Pandas, we can perform a reverse operation by using loc(), iloc(), reindex(), slicing, and indexing on a row of a data set. Creating Dataframe Letâs create a simple data frame with a dictionar 3 min read Like