Skip to content

scatter plot and hexbin plot lose x-axis when colorbar is included. #20446

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 85 commits into from
Jul 4, 2018
Merged
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
e2abff6
removed colorbars from _handle_shared_axes when called by scatterplot…
javadnoorb Mar 22, 2018
0ea226f
removed colorbars from _handle_shared_axes when called by scatterplot…
javadnoorb Mar 22, 2018
80f949f
added a debug global variable
javadnoorb Mar 22, 2018
8f52eab
removed whitespaces
javadnoorb Mar 22, 2018
215fb89
Update _core.py
javadnoorb Mar 28, 2018
7c6efe2
Update _core.py
javadnoorb Mar 28, 2018
8c71f60
Update _tools.py
javadnoorb Mar 29, 2018
63b9ee6
included tests for scatterplot and hexbin plot to ensure colorbar doe…
javadnoorb Mar 29, 2018
f401672
Update test_frame.py
javadnoorb Mar 29, 2018
b821474
Update test_frame.py
javadnoorb Mar 29, 2018
52c1fa8
Update _tools.py
javadnoorb Mar 29, 2018
edf008d
fixing assert message
javadnoorb Mar 29, 2018
db6cf67
Update test_frame.py
javadnoorb Mar 29, 2018
186a09c
fixing style issues
javadnoorb Mar 29, 2018
e6980f3
DOC: Improve the docstrings of CategoricalIndex.map (#20286)
l736x Mar 22, 2018
cdc0240
DOC: update the DataFrame.to_hdf() docstirng (#20186)
shelvinskyi Mar 22, 2018
4848dea
DOC: enable docstring on DataFrame.columns/index (#20385)
jorisvandenbossche Mar 22, 2018
5aed4b5
DOC: general docstring formatting fixes (#20449)
jorisvandenbossche Mar 22, 2018
e2053c9
parameterize tests in scalar/timedelta (#20428)
minggli Mar 22, 2018
268fcf6
API & BUG: allow list-like y argument to df.plot & fix integer arg to…
masongallo Mar 22, 2018
3a76199
Removed dead groupby code (#20457)
WillAyd Mar 22, 2018
189dd8e
EHN: allow zip compression in `to_pickle`, `to_json`, `to_csv` (#20394)
minggli Mar 22, 2018
c302b04
ENH: Sorting of ExtensionArrays (#19957)
TomAugspurger Mar 22, 2018
faefc89
DOC: Improve the docstring of DataFrame.transpose() (#20254)
igorcadelima Mar 23, 2018
4a77c96
DOC: Update pandas.Series.copy docstring (#20261)
thismakessand Mar 23, 2018
e03b4b8
DOC: update the pandas.DataFrame.plot.box docstring (#20373)
4kxz Mar 23, 2018
5ffb078
DOC: make deprecation warning more visible with red box (#20357)
Imanflow Mar 23, 2018
689b3fe
TST: clean deprecation warnings & some parametrizing (#20467)
jreback Mar 23, 2018
7f97c13
REF: Mock all S3 Tests (#20409)
TomAugspurger Mar 23, 2018
9dd5111
TST: Fixed version comparison (#20469)
TomAugspurger Mar 24, 2018
10db32e
TST: 32-bit compat for categorical factorization tests (#20482)
jreback Mar 25, 2018
c1cbd96
API: Preserve int columns in to_dict('index') (#20444)
reidy-p Mar 25, 2018
cfad93f
DOC: Fix broken dependency links (#20471)
tv3141 Mar 25, 2018
f3eaa55
DOC: update the pandas.Series.str.startswith docstring (#20458)
dcreekp Mar 25, 2018
daa3b33
BUG: dropna() on single column timezone-aware values (#13407) (#20422)
JQGoh Mar 25, 2018
40a91c5
TST: test_nanops some parametrize & catch warnings (RuntimeWarning: A…
jreback Mar 26, 2018
eecb129
ENH: DataFrame.pivot accepts a list of values (#18636)
ibrahimsharaf Mar 26, 2018
31f7dc2
BUG: raise error when setting cached properties (#20487)
jorisvandenbossche Mar 26, 2018
56ca9a3
DOC: update the DataFrame.stack docstring (#20430)
samuelsinayoko Mar 26, 2018
492130b
CI: Fixed deprecationWarning (#20489)
TomAugspurger Mar 26, 2018
f02b82b
DOC: update the isna, isnull, notna and notnull docstring (#20459)
Cheukting Mar 26, 2018
9778c85
CLN: remove deprecated infer_dst keyword (#20490)
jorisvandenbossche Mar 27, 2018
a346778
Parametrized NA sentinel for factorize (#20473)
TomAugspurger Mar 27, 2018
b4365e8
DEPR: deprecate get_ftype_counts (GH18243) (#20404)
GGordonGordon Mar 27, 2018
15b7138
DOC: update the Series.str.join docstring (#20463)
fdroessler Mar 27, 2018
b0143e5
ENH/API: ExtensionArray.factorize (#20361)
TomAugspurger Mar 27, 2018
e6c2945
DOC: update vendored numpydoc version
jorisvandenbossche Mar 16, 2018
d2e23f8
DOC: change to numpydoc: add option to use member listing for attributes
jorisvandenbossche Mar 16, 2018
91e5e6b
DOC: change to numpydoc: use isdatadescriptor instead of isgetsetdesc…
jorisvandenbossche Mar 27, 2018
4c6688d
DOC: use numpydoc_use_blockquotes=False for compatibility
jorisvandenbossche Mar 16, 2018
3e91555
DOC: docstring to series.unique (#20474)
minggli Mar 23, 2018
71dff0d
DOC: add guide on shared docstrings (#20016)
TomAugspurger Mar 28, 2018
72524e8
Set pd.options.display.max_columns=0 by default (#17023)
cbrnr Mar 28, 2018
fd08b9f
DOC: whatsnew edits
jreback Mar 28, 2018
3549eca
ENH: Support ExtensionArray in Groupby (#20502)
TomAugspurger Mar 28, 2018
223ae0a
DOC: update the pandas.Series.str.endswith docstring (#20491)
dcreekp Mar 28, 2018
f067b47
DOC: Improving the docstring of Series.str.upper and related (#20462)
Hamishpk Mar 28, 2018
aa1dbd2
DOC: update the Series.between docstring (#20443)
mrw34 Mar 28, 2018
86f17cb
CLN: Removed not necessary bn switch decorator on nansum (#20481)
Mar 29, 2018
3d47aec
DOC: Fix various warnings (#20509)
TomAugspurger Mar 29, 2018
0c3c723
DOC: whatsnew edits
jreback Mar 29, 2018
145d75c
DOC: Add comparison with Stata page to documentation (#19945)
kylebarron Mar 29, 2018
64a2a55
DOC: Update missing_data.rst (#20424)
pulkitmaloo Mar 29, 2018
41cdfdc
Update v0.23.0.txt
javadnoorb Mar 29, 2018
c8ff378
Merge branch 'master' into master
javadnoorb Mar 29, 2018
48291ef
Update test_frame.py
javadnoorb Mar 29, 2018
09c7636
remove whitespace
javadnoorb Mar 30, 2018
864420b
Inline backend (#2)
javadnoorb Apr 10, 2018
eb123be
Update _tools.py
javadnoorb Apr 10, 2018
1fb4eec
Update _core.py
javadnoorb Apr 10, 2018
0397999
Update _core.py
javadnoorb Apr 10, 2018
5ba105f
Update v0.23.0.txt
javadnoorb Apr 10, 2018
ad1b495
Update _core.py
javadnoorb Apr 10, 2018
bdc7f5a
Inline backend - fixing colorbar axis position roundoff error locally
javadnoorb Apr 13, 2018
e656f6e
broken merge
javadnoorb Apr 13, 2018
1e4efd3
Merge remote-tracking branch 'upstream/master'
javadnoorb Apr 23, 2018
45aea6f
Merge remote-tracking branch 'upstream/master'
javadnoorb Apr 24, 2018
eeb6a9f
update fork
javadnoorb Jun 30, 2018
a802ecf
refactoring
javadnoorb Jun 30, 2018
8d766ae
refactoring
javadnoorb Jun 30, 2018
4f380b2
updating whatsnew docs
javadnoorb Jun 30, 2018
04ff768
updating whatsnew docs
javadnoorb Jun 30, 2018
8c0f2e5
updating whatsnew docs
javadnoorb Jun 30, 2018
564790f
updating whatsnew docs
javadnoorb Jun 30, 2018
7196d6e
added more comments
javadnoorb Jul 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DOC: update the DataFrame.stack docstring (#20430)
  • Loading branch information
samuelsinayoko authored and javadnoorb committed Mar 29, 2018
commit 56ca9a35c5d619da0dda757a70d23118aee9e941
176 changes: 153 additions & 23 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5250,36 +5250,166 @@ def pivot_table(self, values=None, index=None, columns=None,

def stack(self, level=-1, dropna=True):
"""
Pivot a level of the (possibly hierarchical) column labels, returning a
DataFrame (or Series in the case of an object with a single level of
column labels) having a hierarchical index with a new inner-most level
of row labels.
The level involved will automatically get sorted.
Stack the prescribed level(s) from columns to index.

Return a reshaped DataFrame or Series having a multi-level
index with one or more new inner-most levels compared to the current
DataFrame. The new inner-most levels are created by pivoting the
columns of the current dataframe:

- if the columns have a single level, the output is a Series;
- if the columns have multiple levels, the new index
level(s) is (are) taken from the prescribed level(s) and
the output is a DataFrame.

The new index levels are sorted.

Parameters
----------
level : int, string, or list of these, default last level
Level(s) to stack, can pass level name
dropna : boolean, default True
Whether to drop rows in the resulting Frame/Series with no valid
values
level : int, str, list, default -1
Level(s) to stack from the column axis onto the index
axis, defined as one index or label, or a list of indices
or labels.
dropna : bool, default True
Whether to drop rows in the resulting Frame/Series with
missing values. Stacking a column level onto the index
axis can create combinations of index and column values
that are missing from the original dataframe. See Examples
section.

Returns
-------
DataFrame or Series
Stacked dataframe or series.

See Also
--------
DataFrame.unstack : Unstack prescribed level(s) from index axis
onto column axis.
DataFrame.pivot : Reshape dataframe from long format to wide
format.
DataFrame.pivot_table : Create a spreadsheet-style pivot table
as a DataFrame.

Notes
-----
The function is named by analogy with a collection of books
being re-organised from being side by side on a horizontal
position (the columns of the dataframe) to being stacked
vertically on top of of each other (in the index of the
dataframe).

Examples
----------
>>> s
a b
one 1. 2.
two 3. 4.
--------
**Single level columns**

>>> df_single_level_cols = pd.DataFrame([[0, 1], [2, 3]],
... index=['cat', 'dog'],
... columns=['weight', 'height'])

Stacking a dataframe with a single level column axis returns a Series:

>>> df_single_level_cols
weight height
cat 0 1
dog 2 3
>>> df_single_level_cols.stack()
cat weight 0
height 1
dog weight 2
height 3
dtype: int64

>>> s.stack()
one a 1
b 2
two a 3
b 4
**Multi level columns: simple case**

>>> multicol1 = pd.MultiIndex.from_tuples([('weight', 'kg'),
... ('weight', 'pounds')])
>>> df_multi_level_cols1 = pd.DataFrame([[1, 2], [2, 4]],
... index=['cat', 'dog'],
... columns=multicol1)

Stacking a dataframe with a multi-level column axis:

>>> df_multi_level_cols1
weight
kg pounds
cat 1 2
dog 2 4
>>> df_multi_level_cols1.stack()
weight
cat kg 1
pounds 2
dog kg 2
pounds 4

**Missing values**

>>> multicol2 = pd.MultiIndex.from_tuples([('weight', 'kg'),
... ('height', 'm')])
>>> df_multi_level_cols2 = pd.DataFrame([[1.0, 2.0], [3.0, 4.0]],
... index=['cat', 'dog'],
... columns=multicol2)

It is common to have missing values when stacking a dataframe
with multi-level columns, as the stacked dataframe typically
has more values than the original dataframe. Missing values
are filled with NaNs:

>>> df_multi_level_cols2
weight height
kg m
cat 1.0 2.0
dog 3.0 4.0
>>> df_multi_level_cols2.stack()
height weight
cat kg NaN 1.0
m 2.0 NaN
dog kg NaN 3.0
m 4.0 NaN

**Prescribing the level(s) to be stacked**

The first parameter controls which level or levels are stacked:

>>> df_multi_level_cols2.stack(0)
kg m
cat height NaN 2.0
weight 1.0 NaN
dog height NaN 4.0
weight 3.0 NaN
>>> df_multi_level_cols2.stack([0, 1])
cat height m 2.0
weight kg 1.0
dog height m 4.0
weight kg 3.0
dtype: float64

Returns
-------
stacked : DataFrame or Series
**Dropping missing values**

>>> df_multi_level_cols3 = pd.DataFrame([[None, 1.0], [2.0, 3.0]],
... index=['cat', 'dog'],
... columns=multicol2)

Note that rows where all values are missing are dropped by
default but this behaviour can be controlled via the dropna
keyword parameter:

>>> df_multi_level_cols3
weight height
kg m
cat NaN 1.0
dog 2.0 3.0
>>> df_multi_level_cols3.stack(dropna=False)
height weight
cat kg NaN NaN
m 1.0 NaN
dog kg NaN 2.0
m 3.0 NaN
>>> df_multi_level_cols3.stack(dropna=True)
height weight
cat m 1.0 NaN
dog kg NaN 2.0
m 3.0 NaN
"""
from pandas.core.reshape.reshape import stack, stack_multiple

Expand Down