How to write Pandas DataFrame as TSV using Python? Last Updated : 05 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 = {'name': ['a', 'b', 'c', 'd'], 'age': [24, 65, 39, 18]} # creating the DataFrame df = pd.DataFrame(sample) # displaying the DataFrame print(df) Output: name age 0 a 24 1 b 65 2 c 39 3 d 18 Now, let's export this as a TSV file. We can use to_csv method from pandas for this. Syntax: df.to_csv(" file.tsv", sep = "") Example: Python3 # saving as tsv file df.to_csv('example.tsv', sep="\t") Output: Here, sep defines what is the separator which separates the data entries in the file. In this case, we define it as a tabspace ('\t'). It will create a .csv file by default if the separator is not defined. Comment More infoAdvertise with us Next Article How to write Pandas DataFrame as TSV using Python? J jayanth1archer Follow Improve Article Tags : Python Python-pandas Python pandas-io 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 Pandas - DataFrame to CSV file using tab separator Let's see how to convert a DataFrame to a CSV file using the tab separator. We will be using the to_csv() method to save a DataFrame as a csv file. To save the DataFrame with tab separators, we have to pass "\t" as the sep parameter in the to_csv() method. Approach :Â Import the Pandas and Numpy mod 1 min read Pandas Dataframe/Series.head() method - Python The head() method structure and contents of our dataset without printing everything. By default it returns the first five rows but this can be customized to return any number of rows. It is commonly used to verify that data has been loaded correctly, check column names and inspect the initial record 3 min read Pandas Dataframe/Series.head() method - Python The head() method structure and contents of our dataset without printing everything. By default it returns the first five rows but this can be customized to return any number of rows. It is commonly used to verify that data has been loaded correctly, check column names and inspect the initial record 3 min read Pandas Dataframe/Series.head() method - Python The head() method structure and contents of our dataset without printing everything. By default it returns the first five rows but this can be customized to return any number of rows. It is commonly used to verify that data has been loaded correctly, check column names and inspect the initial record 3 min read Like