Skip to content
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

API: DataFrame.melt(), DataFrame.wide_to_long() #14876

Closed
jreback opened this issue Dec 13, 2016 · 4 comments
Closed

API: DataFrame.melt(), DataFrame.wide_to_long() #14876

jreback opened this issue Dec 13, 2016 · 4 comments
Labels
API Design Needs Discussion Requires discussion from core team before further action Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@jreback
Copy link
Contributor

jreback commented Dec 13, 2016

xref #14779

So I think it might be nice to have these as convenience methods on DataFrame().
we can deprecate (pd.melt & pd.wide_to_long), though we didn't deprecate pd.pivot_table, even though it exists on DataFrame, so this can be a discussion point.

but if we do this, then maybe have a shorter / better name than wide_to_long? (even though it is strictly speaking pretty informative).

@jreback jreback added API Design Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Dec 13, 2016
@jreback
Copy link
Contributor Author

jreback commented Dec 13, 2016

cc @Nuffe

@erikcs
Copy link
Contributor

erikcs commented Dec 14, 2016

Yes the nomenclature could probably be a bit confusing. Hadley Wickham introduced melt ("long") and cast ("wide") in the reshape2 package as a more user friendly interface to base R's reshape. However, one still have to resort to base R's reshape if one have more groups with common "stubs" like in pd.wide_to_long's doc string examples.

pd.melt is the functional equivalent, and I think any combination of unstack/reset_index would mimic cast? (and I guess also the right combination of stack/reset_index would be able to mimic pd.melt?)

In the Stata camp there is just reshape which takes an additional direction parameter (wide or long) and a list of stub names. pd.wide_to_long is really just solving the use case mentioned above (where R users have to go back to reshape) by mimicking the Stata approach.

So in a "taxonomy of reshapes", pd.wide_to_long is just a special case of pd.melt, perhaps melt_stubs? : P

@jorisvandenbossche jorisvandenbossche added the Needs Discussion Requires discussion from core team before further action label Dec 14, 2016
@ResidentMario
Copy link
Contributor

We didn't discuss wide_to_long in the lead-up to PR#15521. @jorisvandenbossche is there a consensus here that this ought to be done, but that the right method signature is still TBD?

jreback pushed a commit that referenced this issue Apr 4, 2017
xref #12640
xref #14876

Author: Aleksey Bilogur <[email protected]>

Closes #15521 from ResidentMario/12640 and squashes the following commits:

1657246 [Aleksey Bilogur] two doc changes
28a38f2 [Aleksey Bilogur] tweak whatsnew entry.
5f306a9 [Aleksey Bilogur] +whatsnew
ff895fe [Aleksey Bilogur] Add tests, update docs.
11f3fe4 [Aleksey Bilogur] rm stray debug.
3cbbed5 [Aleksey Bilogur] Melt docstring.
d54dc2f [Aleksey Bilogur] +pd.DataFrame.melt.
@jreback
Copy link
Contributor Author

jreback commented Apr 4, 2017

closing this for #15521 was merged. We can discuss later what we are doing in `wide_to_long``

@jreback jreback closed this as completed Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Needs Discussion Requires discussion from core team before further action Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

4 participants