Skip to content

DOC: Added example to MultiIndex doc string #17653

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 2 commits into from
Sep 25, 2017

Conversation

topper-123
Copy link
Contributor

  • closes #xxxx
  • tests added / passed
  • [x ] passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

I think MultiIndex doc string should have a quick note on how MultiIndex is typically instantiated, as you normally wouldn't instantiate it directly.

I've added an example to the doc string, as in my experience MultiIndex is one of the more complex areas of Pandas, so a quick example is justified. This may be debatable, so if others disagree on having an example here, I can remove the example and just retain the links to the .from_* methods.

@topper-123 topper-123 changed the title Added example to MultiIndex doc string DOC: Added example to MultiIndex doc string Sep 24, 2017
DataFrame, e.g.:

>>> pd.Series([1, 2, 3, 4], index=mi)

Copy link
Contributor

Choose a reason for hiding this comment

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

actually adding a See Also section would be good (as then links are generated)

>>> mi = MultiIndex.from_arrays(arrays, names=('number', 'color'))
>>> mi

Such a ``MultiIndex`` instance can be used as an index in a Series or
Copy link
Contributor

Choose a reason for hiding this comment

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

this last part is not really relevant

you can certainly link to a MI (and Index) from Series / DataFrame constructor though

@codecov
Copy link

codecov bot commented Sep 24, 2017

Codecov Report

Merging #17653 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17653      +/-   ##
==========================================
- Coverage   91.26%   91.24%   -0.02%     
==========================================
  Files         163      163              
  Lines       49776    49776              
==========================================
- Hits        45426    45417       -9     
- Misses       4350     4359       +9
Flag Coverage Δ
#multiple 89.03% <ø> (ø) ⬆️
#single 40.28% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/multi.py 96.9% <ø> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.77% <0%> (-0.1%) ⬇️

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 d43aba8...0c36dc1. Read the comment docs.

@codecov
Copy link

codecov bot commented Sep 24, 2017

Codecov Report

Merging #17653 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17653      +/-   ##
==========================================
- Coverage   91.26%   91.24%   -0.02%     
==========================================
  Files         163      163              
  Lines       49806    49806              
==========================================
- Hits        45455    45446       -9     
- Misses       4351     4360       +9
Flag Coverage Δ
#multiple 89.04% <ø> (ø) ⬆️
#single 40.3% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/multi.py 96.9% <ø> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.73% <0%> (-0.1%) ⬇️

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 6da85b3...0daf641. Read the comment docs.

@topper-123 topper-123 force-pushed the multiindex_examples branch 2 times, most recently from fa1ecb6 to eea2e7e Compare September 24, 2017 09:49
@topper-123
Copy link
Contributor Author

I've made changes.

In addition, I've also added a Notes section, with a link to the user guide section on MultiIndex.


Notes
-----
See the :ref:`user guide <advanced>` for more.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you have to put the full http link here (technically you don't for the built docs), but in a console this won't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. done.

@jreback jreback added the Docs label Sep 24, 2017
@jreback jreback added this to the 0.21.0 milestone Sep 24, 2017
@pep8speaks
Copy link

pep8speaks commented Sep 24, 2017

Hello @topper-123! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on September 25, 2017 at 08:12 Hours UTC

See the `user guide
<http://pandas.pydata.org/pandas-docs/stable/advanced.html>`_ for more.

See also
Copy link
Contributor

Choose a reason for hiding this comment

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

See Also

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

Examples
---------
A new ``MultiIndex`` is typically constructed using one of the helper
methods :attr:`MultiIndex.from_arrays``, :attr:`MultiIndex.from_product``
Copy link
Contributor

Choose a reason for hiding this comment

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

should be :meth:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes. Fixed.

@jorisvandenbossche jorisvandenbossche merged commit 35bcd26 into pandas-dev:master Sep 25, 2017
@jorisvandenbossche
Copy link
Member

@topper-123 Thanks! It's really nice to see all those doc improvements!

@topper-123 topper-123 deleted the multiindex_examples branch September 26, 2017 09:40
alanbato pushed a commit to alanbato/pandas that referenced this pull request Nov 10, 2017
No-Stream pushed a commit to No-Stream/pandas that referenced this pull request Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants