+1 vote
in Programming Languages by (73.6k points)
I want to read a gzipped TSV file as a Pandas dataframe. Which function should I use for it?

1 Answer

+2 votes
by (60.2k points)
selected by
 
Best answer

The read_csv() function of pandas can be used to read a gzipped TSV file. You need to pass compression='gzip' as an argument to this function.

Here is an example of reading a gzipped TSV file with a header:

import pandas as pd

df = pd.read_csv("your_file.gz", sep="\t", header=0, compression="gzip")

The content of the file will be in the dataframe 'df'.


...