Skip to content

API/CLN: Have toplevel pd.pivot mirror pivot instead of pivot_simple #22209

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 12 commits into from
Aug 8, 2018

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke commented Aug 6, 2018

  • closes API: Have pd.pivot mirror pivot instead of pivot_simple #22116

  • tests added / passed

  • passes git diff upstream/master -u -- "*.py" | flake8 --diff

  • whatsnew entry

  • Moved pivot from pandas/core/reshape/reshape.py to pandas/core/reshape/pivot.py

  • Moved pivot_simple and _slow_pivot from pandas/core/reshape/reshape.py to pandas/core/reshape/pivot.py (only used by one panel test)

  • Remapped top level pd.pivot to use pivot instead of pivot_simple

  • Added some additional tests for pd.pivot

@mroeschke mroeschke changed the title CLN: Have toplevel pd.pivot mirror pivot instead of pivot_simple API/CLN: Have toplevel pd.pivot mirror pivot instead of pivot_simple Aug 6, 2018
@gfyoung gfyoung requested a review from jreback August 6, 2018 04:38
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.

small comment, ping when green.

@@ -467,6 +467,7 @@ Other API Changes
- :meth:`PeriodIndex.tz_convert` and :meth:`PeriodIndex.tz_localize` have been removed (:issue:`21781`)
- :class:`Index` subtraction will attempt to operate element-wise instead of raising ``TypeError`` (:issue:`19369`)
- :class:`pandas.io.formats.style.Styler` supports a ``number-format`` property when using :meth:`~pandas.io.formats.style.Styler.to_excel` (:issue:`22015`)
- Top level function :meth:`pandas.pivot` now maps directly to the instance method :meth:`DataFrame.pivot` (:issue:`22116`)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not necessary, you are cleaning internal code and its not user facing

@jreback jreback added the Clean label Aug 6, 2018
@codecov
Copy link

codecov bot commented Aug 6, 2018

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #22209      +/-   ##
==========================================
- Coverage   92.06%   92.06%   -0.01%     
==========================================
  Files         169      169              
  Lines       50698    50687      -11     
==========================================
- Hits        46676    46664      -12     
- Misses       4022     4023       +1
Flag Coverage Δ
#multiple 90.47% <100%> (-0.01%) ⬇️
#single 42.33% <43.47%> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/core/reshape/reshape.py 99.54% <ø> (-0.03%) ⬇️
pandas/core/reshape/api.py 100% <100%> (ø) ⬆️
pandas/core/frame.py 97.26% <100%> (ø) ⬆️
pandas/core/reshape/pivot.py 97.17% <100%> (+0.13%) ⬆️
pandas/util/_depr_module.py 65.11% <0%> (-2.33%) ⬇️

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 737b329...8363d7c. Read the comment docs.

@mroeschke
Copy link
Member Author

Ping @jreback. All green.

@jreback jreback added this to the 0.24.0 milestone Aug 7, 2018
return series.unstack()


def _slow_pivot(index, columns, values):
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we are using this anywhere but the test_panel test? if so I would just blow it away & remove the test

@mroeschke
Copy link
Member Author

@jreback removed those unused methods and test and all green.

@jreback jreback merged commit dfb1b84 into pandas-dev:master Aug 8, 2018
@jreback
Copy link
Contributor

jreback commented Aug 8, 2018

thanks @mroeschke nice clean!

@mroeschke mroeschke deleted the edit_pivot branch August 8, 2018 15:53
@jorisvandenbossche
Copy link
Member

We cannot simply change this, as this completely breaks existing usage of pd.pivot. This needs to go through a deprecation cycle (or need to think how to keep supporting the old usage).

@mroeschke
Copy link
Member Author

We could keep pivot_simple (which was pd.pivot previously) and then add a depreciation warning to pd.pivot that its behavior will mirror df.pivot and to use pivot_simple instead.

@jorisvandenbossche
Copy link
Member

That's certainly an option.
I personally don't really know to what extent it would be useful to also keep the current behaviour of pivot_simple (so to not fully deprecate it). Will open an issue to not forget this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: Have pd.pivot mirror pivot instead of pivot_simple
4 participants