Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I save a Pandas dataframe into a compressed csv file? [duplicate]

I load a very large csv file in a gz format in Pandas 0.18 using

pd=pd.read_csv('myfile.gz')

Without surprise, once the csv is unzipped and loaded into the RAM, it takes a lot of space. However, I still need to save my file after I perform my computations.

Can to_csv store my dataframe in a gz format? The only related question I found on StackOverflow is 3 year old...

like image 799
ℕʘʘḆḽḘ Avatar asked Dec 24 '22 07:12

ℕʘʘḆḽḘ


1 Answers

You could use the parameter compression='gzip'

source

like image 52
Till Avatar answered Feb 05 '23 17:02

Till