-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Support writing CSV to GCS #22704
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
Support writing CSV to GCS #22704
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,21 @@ def test_read_csv_gcs(mock): | |
assert_frame_equal(df1, df2) | ||
|
||
|
||
@td.skip_if_no('gcsfs') | ||
def test_to_csv_gcs(mock): | ||
df1 = DataFrame({'int': [1, 3], 'float': [2.0, np.nan], 'str': ['t', 's'], | ||
'dt': date_range('2018-06-18', periods=2)}) | ||
with mock.patch('gcsfs.GCSFileSystem') as MockFileSystem: | ||
s = StringIO() | ||
instance = MockFileSystem.return_value | ||
instance.open.return_value = s | ||
|
||
df1.to_csv('gs://test/test.csv', index=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any particular reason you are explicitly stating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
df2 = read_csv(StringIO(s.getvalue()), parse_dates=['dt'], index_col=0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to above comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
|
||
assert_frame_equal(df1, df2) | ||
|
||
|
||
@td.skip_if_no('gcsfs') | ||
def test_gcs_get_filepath_or_buffer(mock): | ||
df1 = DataFrame({'int': [1, 3], 'float': [2.0, np.nan], 'str': ['t', 's'], | ||
|
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.
Might be missing the point but if you are patching this what is actually getting tested for gcs?
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.
Yeah, it's kind of the same problem that we discussed in #20729. This does at least test the logic that I touched here; I think ultimately what the mocks assume is that
gcsfs.GCSFileSystem
canread
/write
strings and everything else is using the realpandas
methods.