Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b4fc7c

Browse files
committed
DOC: edits to whats_new entry
1 parent 8271952 commit 0b4fc7c

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

doc/users/whats_new/2015-07-30_unpack_labeled_data.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,34 @@ Working with labeled data like pandas DataFrames
33
Plot methods which take arrays as inputs can now also work with labeled data
44
and unpack such data.
55

6-
This means that the following two examples produce the same plot::
6+
This means that the following two examples produce the same plot:
77

88
Example ::
9+
910
df = pandas.DataFrame({"var1":[1,2,3,4,5,6], "var2":[1,2,3,4,5,6]})
1011
plt.plot(df["var1"], df["var2"])
1112

1213

1314
Example ::
15+
1416
plt.plot("var1", "var2", data=df)
1517

1618
This works for most plotting methods, which expect arrays/sequences as
17-
inputs and ``data`` can be anything which supports ``__get_item__``
18-
(``dict``, ``pandas.DataFrame``,...).
19+
inputs. ``data`` can be anything which supports ``__getitem__``
20+
(``dict``, ``pandas.DataFrame``, ``h5py``, ...) to access ``array`` like
21+
values with string keys.
1922

2023
In addition to this, some other changes were made, which makes working with
21-
``pandas.DataFrames`` easier:
22-
23-
* For plotting methods which understand a ``label`` keyword argument but the
24-
user does not supply such an argument, this is now implicitly set by either
25-
looking up ``.name`` of the right input or by using the label supplied to
26-
lookup the input in ``data``. In the above examples, this results in an
27-
implicit ``label="var2"`` for both cases.
24+
labeled data (ex ``pandas.Series``) easier:
25+
26+
* For plotting methods with ``label`` keyword argument, one of the
27+
data inputs is designated as the label source. If the user does not
28+
supply a ``label`` that value object will be introspected for a
29+
label, currently by looking for a ``name`` attribute. If the value
30+
object does not have a ``name`` attribute but was specified by as a
31+
key into the ``data`` kwarg, then the key is used. In the above
32+
examples, this results in an implicit ``label="var2"`` for both
33+
cases.
2834

2935
* ``plot()`` now uses the index of a ``Series`` instead of
3036
``np.arange(len(y))``, if no ``x`` argument is supplied.

0 commit comments

Comments
 (0)