0
votes

Pandas 0.18 supports read_csv zip file as argument and reading zipped csv table correctly into data frame. But when i am trying to use to_csv() method to save data frame as zipped csv, i am getting error. According to official documentation, zip format not supported in to_csv() method. Any thoughts? Thank you.

import pandas as pd

works fine

data = pd.read_csv("E:\ASML SED.zip")

error out IOError: [Errno 2] No such file or directory: 'E:\ASML SED.zip'

data.to_csv("E:\ASML SED Zipped.zip", compression = 'zip')

1
I'm confused, the documentation says that to_csv supports gzip through the compression attribute. Why do you say it's not supported? Also some sample code would be helpful.shawnheide
To_csv() doesnt support zip, while read_csv() does. Sorry for confusion.Felix
added code exampleFelix

1 Answers

0
votes

Indeed, zip format not supported in to_csv() method according to this official documentation, the allowed values are ‘gzip’, ‘bz2’, ‘xz’.

If you really want the 'zip' format, you can try to save as uncompressed csv file, then using cli to compress the .csv file to .csv.zip.