There is an option in Pandas Dataframes to_csv function to add a compression when saving the data. This is very useful especially when we want to save some space.
#lets use this sample dataframe df=pd.DataFrame({'A':[1,2,3,4]})
Save it as gzip
df.to_csv("dataframe.csv.gz", index=False, compression="gzip")
Save it as zip
df.to_csv("dataframe.csv.zip", index=False, compression="zip")
How to read gzip/zip with Pandas
Pandas can also read gzip/zip files that contain a CSV.
pd.read_csv('dataframe.csv.gz')
A 0 1 1 2 2 3 3 4
pd.read_csv('dataframe.csv.zip')
A 0 1 1 2 2 3 3 4