Skip to content

poor melt example in documentation #23844

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

Open
MLopez-Ibanez opened this issue Nov 21, 2018 · 7 comments
Open

poor melt example in documentation #23844

MLopez-Ibanez opened this issue Nov 21, 2018 · 7 comments
Labels
Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@MLopez-Ibanez
Copy link

MLopez-Ibanez commented Nov 21, 2018

Problem description

The example chosen to illustrate melt

https://pandas.pydata.org/pandas-docs/stable/user_guide/reshaping.html#reshaping-by-melt

is not ideal. Normally, melt would be used to convert from wide to long data. However, the data on the left hand side of the example is already in long format (each variable corresponds to a different column) and the melt command is just creating a strange "thing" where the column value contains two different variables. I'm using this figure in my teaching as an example of what NOT to do when reshaping data.

A better example would be (taken from: https://www.jstatsoft.org/article/view/v059i10)

first last Treatment A Treatment B
Jane Doe 16 11
Mary Johnson 3 1

melted into:

first last variable value
Jane Doe Treatment A 16
Jane Doe Treatment B 11
Mary Johnson Treatment A 3
Mary Johnson Treatment B 1

I'm happy to provide a pull request against the docs if this is considered an improvement.

@gfyoung gfyoung added Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Nov 21, 2018
@gfyoung
Copy link
Member

gfyoung commented Nov 21, 2018

cc @jreback

@MLopez-Ibanez
Copy link
Author

Are the sources of the figures already available somewhere? If not, would it be worth to store the SVG sources in git so that they can be easily edited in the future?

@gfyoung
Copy link
Member

gfyoung commented Nov 25, 2018

@MLopez-Ibanez
Copy link
Author

Those do not seem to be source files (I would expect either a script to recreate the files or svg or some other source format)

@gfyoung
Copy link
Member

gfyoung commented Nov 27, 2018

Ah, sorry, I don't believe we have said files unfortunately...

@MLopez-Ibanez
Copy link
Author

Somebody created the images. Perhaps they have the source files? It would be useful to know at least the fonts and font sizes used, to be consistent.

MLopez-Ibanez added a commit to MLopez-Ibanez/pandas that referenced this issue Aug 18, 2019
@MLopez-Ibanez
Copy link
Author

MLopez-Ibanez commented Sep 11, 2019

  • Another issue is that the figure says df3 but the example uses cheese.

From the closed PR:

Something like a dataframe for GDP, having the id column as a country, and then having columns 2016, 2017 and 2018 with the values could be a good example, easy to understand. Made up values in A, B columns is not.

(Nevertheless that most examples in that page use "A" and "B" as columns...)

The original assets are available here: #28006 (comment)

but they are in non-free formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants