Exporting DTA File Using pandas.DataFrame.to_stata() function in Python Last Updated : 14 Sep, 2021 Comments Improve Suggest changes Like Article Like Report This method is used to writes the DataFrame to a Stata dataset file. “dta” files contain a Stata dataset. DTA file is a database file and it is used by IWIS Chain Engineering. Syntax : DataFrame.to_stata(path, convert_dates=None, write_index=True, time_stamp=None) Parameters : path : str, buffer or path objectconvert_dates : dictwrite_index : booltime_stamp : datetime Returns : DataFrame object to Stata dta format. Means return .dta file. Example 1: Create DTA file Here we will create dataframe and then saving into the DTA format using DataFrame.to_stata(). Python3 # importing package import numpy import pandas as pd # create and view data df = pd.DataFrame({ 'person': ["Rakesh", "Kishan", "Adesh", "Nitish"], 'weight': [50, 60, 70, 80] }) display(df) # use pandas.DataFrame.to_stata method # to extract .dta file df.to_stata('person.dta') Output : Example 2: Python3 # importing package import pandas as pd # create and view data df = pd.DataFrame({ 'mobiles': ["Apple", "MI", "Karban", "JIO"], 'prizes': [75000, 9999, 6999, 5999] }) display(df) # use pandas.DataFrame.to_stata method # to extract .dta file df.to_stata('mobiles.dta') Output : Comment More infoAdvertise with us Next Article Exporting DTA File Using pandas.DataFrame.to_stata() function in Python R rakeshsahni Follow Improve Article Tags : Python Python-pandas Pandas-DataFrame-Methods Practice Tags : python Similar Reads pandas.DataFrame.T() function in Python pandas.DataFrame.T property is used to transpose index and columns of the data frame. The property T is somehow related to method transpose(). Â The main function of this property is to create a reflection of the data frame overs the main diagonal by making rows as columns and vice versa. Syntax: Dat 2 min read Exporting Pandas DataFrame to JSON File Pandas a powerful Python library for data manipulation provides the to_json() function to convert a DataFrame into a JSON file and the read_json() function to read a JSON file into a DataFrame.In this article we will explore how to export a Pandas DataFrame to a JSON file with detailed explanations 2 min read Pandas Functions in Python: A Toolkit for Data Analysis Pandas is one of the most used libraries in Python for data science or data analysis. It can read data from CSV or Excel files, manipulate the data, and generate insights from it. Pandas can also be used to clean data, filter data, and visualize data. Whether you are a beginner or an experienced pro 6 min read How to export Pandas DataFrame to a CSV file? Let us see how to export a Pandas DataFrame to a CSV file. We will be using the to_csv() function to save a DataFrame as a CSV file. DataFrame.to_csv() Syntax : to_csv(parameters) Parameters : path_or_buf : File path or object, if None is provided the result is returned as a string. sep : String of 3 min read How To Convert Sklearn Dataset To Pandas Dataframe In Python In this article, we look at how to convert sklearn dataset to a pandas dataframe in Python. Sklearn and pandas are python libraries that are used widely for data science and machine learning operations. Pandas is majorly focused on data processing, manipulation, cleaning, and visualization whereas s 3 min read Like