-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
ENH #15972 added margins_name parameter for crosstab #16489
Conversation
There was a problem hiding this 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.
pandas/core/reshape/pivot.py
Outdated
Name of the row / column that will contain the totals | ||
when margins is True. | ||
|
||
.. versionadded:: 0.20.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.21.0
pandas/tests/reshape/test_pivot.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line here
pandas/core/reshape/pivot.py
Outdated
table = concat([table, column_margin], axis=1) | ||
print('index margin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove prints
doc/source/whatsnew/v0.20.0.txt
Outdated
@@ -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`) |
There was a problem hiding this comment.
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
ok |
I think you have a conflict on 0.21.0.txt (pls rebase again). |
doc/source/whatsnew/v0.21.0.txt
Outdated
@@ -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`) |
There was a problem hiding this comment.
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.
30edb7f
to
abe70e6
Compare
Codecov Report
@@ Coverage Diff @@
## master #16489 +/- ##
=======================================
Coverage 90.43% 90.43%
=======================================
Files 161 161
Lines 51045 51045
=======================================
Hits 46161 46161
Misses 4884 4884
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comment
doc/source/whatsnew/v0.21.0.txt
Outdated
@@ -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`) |
There was a problem hiding this comment.
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
42a089e
to
d226549
Compare
Thank you for your checking and helpful comments. |
Thanks @cmohl2013 ! |
* 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
* 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
git diff upstream/master --name-only -- '*.py' | flake8 --diff