Skip to content

ENH #15972 added margins_name parameter for crosstab #16489

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 4 commits into from
May 26, 2017

Conversation

cmohl2013
Copy link
Contributor

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.

minor comments. ping on green.

Name of the row / column that will contain the totals
when margins is True.

.. versionadded:: 0.20.0
Copy link
Contributor

Choose a reason for hiding this comment

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

0.21.0

@@ -1071,6 +1071,42 @@ def test_crosstab_margins(self):
exp_rows = exp_rows.fillna(0).astype(np.int64)
tm.assert_series_equal(all_rows, exp_rows)

def test_crosstab_margins_set_margin_name(self):
a = np.random.randint(0, 7, size=100)
Copy link
Contributor

Choose a reason for hiding this comment

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

add the issue number as a comment


all_cols = result['TOTAL', '']
exp_cols = df.groupby(['a']).size().astype('i8')
# to keep index.name
Copy link
Contributor

Choose a reason for hiding this comment

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

blank line here

table = concat([table, column_margin], axis=1)
print('index margin')
Copy link
Contributor

Choose a reason for hiding this comment

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

remove prints

@@ -514,7 +514,7 @@ Other Enhancements
- ``parallel_coordinates()`` has gained a ``sort_labels`` keyword argument that sorts class labels and the colors assigned to them (:issue:`15908`)
- Options added to allow one to turn on/off using ``bottleneck`` and ``numexpr``, see :ref:`here <basics.accelerate>` (:issue:`16157`)
- ``DataFrame.style.bar()`` now accepts two more options to further customize the bar chart. Bar alignment is set with ``align='left'|'mid'|'zero'``, the default is "left", which is backward compatible; You can now pass a list of ``color=[color_negative, color_positive]``. (:issue:`14757`)

- ``Crosstab`` has gained a ``margins_name`` parameter to define the name of the row / column that will contain the totals when margins is True(:issue:`15972`)
Copy link
Contributor

Choose a reason for hiding this comment

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

move to 0.21.0.txt

@jreback jreback added Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels May 24, 2017
@cmohl2013
Copy link
Contributor Author

ok

@jreback
Copy link
Contributor

jreback commented May 24, 2017

I think you have a conflict on 0.21.0.txt (pls rebase again).

@@ -35,6 +35,7 @@ Other Enhancements
- ``RangeIndex.append`` now returns a ``RangeIndex`` object when possible (:issue:`16212`)
- :func:`to_pickle` has gained a protocol parameter (:issue:`16252`). By default, this parameter is set to `HIGHEST_PROTOCOL <https://docs.python.org/3/library/pickle.html#data-stream-format>`__
- :func:`api.types.infer_dtype` now infers decimals. (:issue: `15690`)
- ``Crosstab`` has gained a ``margins_name`` parameter to define the name of the row / column that will contain the totals when margins is True(:issue:`15972`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a space before the ( when you rebase.

@cmohl2013 cmohl2013 force-pushed the crosstable_margins_name branch from 30edb7f to abe70e6 Compare May 25, 2017 09:56
@codecov
Copy link

codecov bot commented May 25, 2017

Codecov Report

Merging #16489 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #16489   +/-   ##
=======================================
  Coverage   90.43%   90.43%           
=======================================
  Files         161      161           
  Lines       51045    51045           
=======================================
  Hits        46161    46161           
  Misses       4884     4884
Flag Coverage Δ
#multiple 88.27% <100%> (ø) ⬆️
#single 40.16% <16.66%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/reshape/pivot.py 95.08% <100%> (ø) ⬆️

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 e81f3cc...b5756ef. Read the comment docs.

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.

minor comment

@@ -35,6 +35,7 @@ Other Enhancements
- ``RangeIndex.append`` now returns a ``RangeIndex`` object when possible (:issue:`16212`)
- :func:`to_pickle` has gained a protocol parameter (:issue:`16252`). By default, this parameter is set to `HIGHEST_PROTOCOL <https://docs.python.org/3/library/pickle.html#data-stream-format>`__
- :func:`api.types.infer_dtype` now infers decimals. (:issue: `15690`)
- ``Crosstab`` has gained a ``margins_name`` parameter to define the name of the row / column that will contain the totals when margins is True. (:issue:`15972`)
Copy link
Contributor

Choose a reason for hiding this comment

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

:func:crosstab

when margins=True

@cmohl2013 cmohl2013 force-pushed the crosstable_margins_name branch from 42a089e to d226549 Compare May 25, 2017 19:45
@cmohl2013
Copy link
Contributor Author

@jreback
@TomAugspurger

Thank you for your checking and helpful comments.

@TomAugspurger TomAugspurger added this to the 0.21.0 milestone May 26, 2017
@TomAugspurger TomAugspurger merged commit b0d9ee0 into pandas-dev:master May 26, 2017
@TomAugspurger
Copy link
Contributor

Thanks @cmohl2013 !

Kiv pushed a commit to Kiv/pandas that referenced this pull request Jun 11, 2017
* ENH pandas-dev#15972 added margins_name parameter for crosstab

* ENH 15972 minor changes as suggested by reviewers

* ENH 15972 correction in whatsnew

* ENH 15972 style changes in whatsnew
stangirala pushed a commit to stangirala/pandas that referenced this pull request Jun 11, 2017
* ENH pandas-dev#15972 added margins_name parameter for crosstab

* ENH 15972 minor changes as suggested by reviewers

* ENH 15972 correction in whatsnew

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

Successfully merging this pull request may close these issues.

Crosstab support for setting the margins name
3 participants