Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to load a TSV file into a Pandas DataFrame?

  • Last Updated : 18 Oct, 2021

In this article, we will discuss how to load a TSV file into a Pandas Dataframe.

The idea is extremely simple we only have to first import all the required libraries and then load the data set by the use of read_csv() method. To this method simply the path of the dataframe is passed. This is enough to get the job done.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Syntax :



pandas.read_csv(path, sep=’\t’)

Given below are some implementations for the same.

Example 1: Loading a TSV dataset into pandas dataframe

Dataset Used:  data.tsv

Python3




import pandas as pd
  
# Data.tsv is stored locally in the 
# same directory as of this python file
df = pd.read_csv('data.tsv',sep = '\t'
df

Output:

Example 2: Loading a TSV dataset into pandas dataframe

Dataset used: babynames.tsv

Python3




import pandas as pd
  
df = pd.read_csv('babynames.tsv', sep = '\t')
df

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!