-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: added compression kw to to_csv GH7615 #11219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I need help from pandas people (@jreback ?)
I assume "not writable" means that the file I'm trying to write to, which I got using |
and does it work locally for you? |
I couldn't build ( |
pls read the contributing docs here creation of the proper build env is pretty easy using conda (and even local tools on linux, but windows we recommend conda as its dead simple). docker is much too heavyweight for most things iMHO. pls build and debug locally first. |
I had problems building pandas ( Test problem and solution Build problem and solution
and if you already tried |
@@ -1431,7 +1432,7 @@ def save(self): | |||
close = False | |||
else: | |||
f = com._get_handle(self.path_or_buf, self.mode, | |||
encoding=self.encoding) | |||
encoding=self.encoding, compression=self.compression) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add this on the next line
pls add a release note in 0.17.1 (enhancements section), and squash. |
Sure thing. I've never 'squashed' before - any comments/instructions beyond the |
nope, that says it all |
0c78d96
to
9bd5d24
Compare
Fixed following code review (d3f63d8). |
7193924
to
19e97fb
Compare
OK this was fun, I learned a lot. Thanks. |
looks good. pls add a whatsnew note in enhancements for 0.17.1 |
Right. I did it but it got lost when I squashed. I'll do it again and squash properly. |
@@ -2847,11 +2847,11 @@ def _get_handle(path, mode, encoding=None, compression=None): | |||
|
|||
if compression == 'gzip': | |||
import gzip | |||
f = gzip.GzipFile(path, 'rb') | |||
f = gzip.GzipFile(path, mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this defaults to rb
or wb
as appropriate, but should this be passed by the caller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as I cant tell, if we don't pass mode
then it will default to rb
and then to_csv
will fail.
@@ -7328,6 +7328,52 @@ def test_to_csv_path_is_none(self): | |||
recons = pd.read_csv(StringIO(csv_str), index_col=0) | |||
assert_frame_equal(self.frame, recons) | |||
|
|||
def test_to_csv_compression_gzip(self): | |||
## GH7615 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a test to ensure that the ValueError
is raised when passing an invalid string as compression
Anything else comes to mind? |
ENH: added compression kw to to_csv GH7615
thank you sir! |
Thank you, I've enjoyed the process and learned much. |
This closes #7615 and represents work that started in #2636.