-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the pandas.DataFrame.plot.pie docstring #20133
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2835,18 +2835,42 @@ def area(self, x=None, y=None, **kwds): | |
|
||
def pie(self, y=None, **kwds): | ||
""" | ||
Pie chart | ||
Generate a pie plot. | ||
|
||
A pie plot is a representation of the distribution of numerical data | ||
in a DataFrame column. This function wraps the `matplotlib.pyplot.pie` | ||
function for specified column. If no column reference is passed and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. refer to 'y' here (its the column reference) |
||
``subplots`` argument is set to ``True``, an np.array of plots for | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can use single backticks for 'subplots' (because it is a reference to a parameter) |
||
all DataFrame columns will be returned. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
Parameters | ||
---------- | ||
y : label or position, optional | ||
Column to plot. | ||
`**kwds` : optional | ||
y : str or int, optional | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit a corner case as well, but in another PR we decide to keep the 'label', as 'str' can actually be too strict on the column name (column names can be other things as strings) .. |
||
Label or position of the column to plot. | ||
If not provided, ``subplots=True`` argument must be passed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really? What happens if we don't pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. This error is raised: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improvement proposal: |
||
**kwds : optional | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no ** on kwds There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jreback there is a huge confusion here. @datapythonista said we DO want ** on kwds and they are modifying the validation script to accept it. Now you say we don't want it. Can we make a decision about this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jreback we decided to keep them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jreback I thought the consensus was to have them. We've got a bug in the script that was validating the opposite, which created some confusion, but in the documentation we've got that they should have the If there is no final decision, I'd accept both. I think it should be quite easy to use |
||
Keyword arguments to pass on to :py:meth:`pandas.DataFrame.plot`. | ||
|
||
Returns | ||
------- | ||
axes : matplotlib.AxesSubplot or np.array of them | ||
axes : matplotlib.AxesSubplot or np.array of them. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain here when an array is returned? |
||
|
||
See Also | ||
-------- | ||
:meth:`pandas.Series.plot.pie` : Generate a pie plot for a Series. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can leave out the I would also add the see also to matplotlib.pyplot.pie |
||
|
||
Examples | ||
-------- | ||
In the example below we have a DataFrame with the information about | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps a matter of style, but I'd say:
Because the fact that it is an example can be determined from the section it is in, and the fact that we pass the 'mass' column to the What about another example without specifying the |
||
planet's mass and radius. We pass the the 'mass' column to the | ||
pie function to get a pie plot. | ||
|
||
.. plot:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add some text above explaining what is the example about in plain English? Also, perhaps you want to create different plots for different |
||
:context: close-figs | ||
|
||
>>> df = pd.DataFrame({'mass': [0.330, 4.87 , 5.97], | ||
... 'radius': [2439.7, 6051.8, 6378.1]}) | ||
>>> plot = df.plot.pie(y='mass', labels=['Mercury', 'Venus', 'Earth']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe also add an example with the subplots argument? |
||
""" | ||
return self(kind='pie', y=y, **kwds) | ||
|
||
|
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.
for the specified column