Skip to content

Fix to_csv of DataFrame with single level multiindex. #19831

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

Merged
merged 1 commit into from
Nov 1, 2018
Merged

Fix to_csv of DataFrame with single level multiindex. #19831

merged 1 commit into from
Nov 1, 2018

Conversation

EricChea
Copy link
Contributor

@EricChea EricChea commented Feb 21, 2018

What's this PR do?

Fixes the output of to_csv to show the value instead of the tuple when a DataFrame or Series is constructed using a MultiIndex with one level. Although, I'm not sure if it's more desirable to require a MultiIndex to be instantiated with more than one level in the future.

@jreback jreback added Output-Formatting __repr__ of pandas objects, to_string IO CSV read_csv, to_csv MultiIndex labels Feb 22, 2018
@codecov
Copy link

codecov bot commented Feb 22, 2018

Codecov Report

Merging #19831 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19831      +/-   ##
==========================================
- Coverage   92.21%   92.21%   -0.01%     
==========================================
  Files         161      161              
  Lines       51173    51176       +3     
==========================================
+ Hits        47190    47192       +2     
- Misses       3983     3984       +1
Flag Coverage Δ
#multiple 90.64% <100%> (-0.01%) ⬇️
#single 42.23% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/multi.py 95.38% <100%> (-0.08%) ⬇️
pandas/core/dtypes/base.py 100% <0%> (ø) ⬆️
pandas/core/dtypes/missing.py 93.1% <0%> (ø) ⬆️
pandas/core/dtypes/inference.py 98.38% <0%> (ø) ⬆️
pandas/core/dtypes/dtypes.py 95.61% <0%> (ø) ⬆️
pandas/core/dtypes/common.py 94.37% <0%> (ø) ⬆️
pandas/core/dtypes/cast.py 88.92% <0%> (ø) ⬆️
pandas/core/dtypes/concat.py 96.34% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de39bfc...bdc20d4. Read the comment docs.

@TomAugspurger
Copy link
Contributor

Fixed the merge conflict, and the whatsnew note.

Ping on green.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you rebase on master and will have a look

@pep8speaks
Copy link

Hello @EricChea! Thanks for updating the PR.

@gfyoung gfyoung modified the milestones: 0.25.0, 0.24.0 Oct 31, 2018
@gfyoung
Copy link
Member

gfyoung commented Oct 31, 2018

@jreback @TomAugspurger : Addressed all comments. Everything is green except for the fact that hypothesis is timing out on an unrelated test:

https://travis-ci.org/pandas-dev/pandas/jobs/448750638#L2895

@jreback
Copy link
Contributor

jreback commented Oct 31, 2018

i thought the hypothesis stuff was fixed for timeout
can we do a precursor PR to address this?

@gfyoung
Copy link
Member

gfyoung commented Oct 31, 2018

i thought the hypothesis stuff was fixed for timeout

I'm pretty sure it was fixed but not sure why it's complaining:

hypothesis.settings.register_profile(

cc @Zac-HD

Display the level by itself instead of as a tuple
(i.e. "squash" the MultiIndex into a single level)

Closes gh-19589.
@gfyoung
Copy link
Member

gfyoung commented Oct 31, 2018

@jreback @TomAugspurger : Everything is green now. Maybe Travis was just acting up. PTAL.

@Zac-HD
Copy link
Contributor

Zac-HD commented Oct 31, 2018

Gah, it's warning about the not-yet-enforced deadline setting, which -Werror is turning into an error. This is almost certainly just due to a slow VM on Travis, but if you want I can open a PR to fix that this evening 😞

@gfyoung
Copy link
Member

gfyoung commented Oct 31, 2018

This is almost certainly just due to a slow VM on Travis

@Zac-HD : Indeed, that is what I suspect as well. If you could open a PR to make our tests more robust against this, that would be great!

@jreback jreback merged commit 16c0bbb into pandas-dev:master Nov 1, 2018
@jreback
Copy link
Contributor

jreback commented Nov 1, 2018

thanks @EricChea , @Zac-HD , and @gfyoung

tm9k1 pushed a commit to tm9k1/pandas that referenced this pull request Nov 19, 2018
Display the level by itself instead of as a tuple
(i.e. "squash" the MultiIndex into a single level)

Closes pandas-devgh-19589.
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Display the level by itself instead of as a tuple
(i.e. "squash" the MultiIndex into a single level)

Closes pandas-devgh-19589.
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Display the level by itself instead of as a tuple
(i.e. "squash" the MultiIndex into a single level)

Closes pandas-devgh-19589.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO CSV read_csv, to_csv MultiIndex Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

to_csv() with a single level row MultiIndex does not produce the desired output
6 participants