-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: Fix problem with SparseDataFrame not persisting to csv #19441
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
pandas/core/internals.py
Outdated
@@ -704,7 +704,9 @@ def to_native_types(self, slicer=None, na_rep='nan', quoting=None, | |||
**kwargs): | |||
""" convert to our native types format, slicing if desired """ | |||
|
|||
values = self.values | |||
# values = self.values |
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.
you can remove the comment
@@ -253,3 +253,12 @@ def test_to_csv_string_array_utf8(self): | |||
df.to_csv(path, encoding='utf-8') | |||
with open(path, 'r') as f: | |||
assert f.read() == expected_utf8 | |||
|
|||
def test_to_csv_sparse_dataframe(self): | |||
sdf = pd.SparseDataFrame({'a': [1, 2]}) |
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 a comment here for the issue number. I would rather have this test in pandas/tests/sparse/frame/test_to_csv.py
can you add several variations, e.g. using fill value and with some nulls.
Hello @hexgnu! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on February 01, 2018 at 13:26 Hours UTC |
K updated thanks @jreback |
@hexgnu do the tests you've written pass for you locally? |
oi sorry, should pass now. |
Still one lint failure: https://travis-ci.org/pandas-dev/pandas/jobs/335405859#L3035 I'm looking into the (unrelated) S3 failures later this morning. |
Codecov Report
@@ Coverage Diff @@
## master #19441 +/- ##
==========================================
+ Coverage 91.62% 91.67% +0.05%
==========================================
Files 150 148 -2
Lines 48724 48553 -171
==========================================
- Hits 44642 44513 -129
+ Misses 4082 4040 -42
Continue to review full report at Codecov.
|
Ok for real this time it passed @jreback @TomAugspurger thanks 😄 |
def test_to_csv_sparse_dataframe(): | ||
fill_values = [np.nan, 0, None, 1] | ||
|
||
for fill_value in fill_values: |
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 parameterize
|
||
|
||
def test_to_csv_sparse_dataframe(): | ||
fill_values = [np.nan, 0, None, 1] |
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 the issue number here as well
doc/source/whatsnew/v0.23.0.txt
Outdated
@@ -497,7 +497,7 @@ I/O | |||
- Bug in :func:`DataFrame.to_parquet` where an exception was raised if the write destination is S3 (:issue:`19134`) | |||
- :class:`Interval` now supported in :func:`DataFrame.to_excel` for all Excel file types (:issue:`19242`) | |||
- :class:`Timedelta` now supported in :func:`DataFrame.to_excel` for xls file type (:issue:`19242`, :issue:`9155`) | |||
- | |||
- Bug in :class:`SparseDataFrame.to_csv` where too many indices for values (:issue:`19384`) |
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.
move to sparse, and don't need this kind of detail, just say was raising.
a lint error.ping when pushed and green. |
great. ping on green. |
Thanks @hexgnu! |
…ev#19441) * BUG: Fix problem with SparseDataFrame not persisting to csv * FIX: Remove comment and move test with more coverage * FIX: Flake8 issues cleanup * Fix failing test due to blank lines * FIX: linting errors on whitespace * Use parametrize on test * Move bug description to sparse header * Add GH issue to test * Fix linting error
git diff upstream/master -u -- "*.py" | flake8 --diff