Skip to content

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Aug 30, 2017

This pull request adds some examples to Index.get_loc (actually to Index._index_shared_docs['get_loc']) and clarifies the return value.

@pep8speaks
Copy link

pep8speaks commented Aug 30, 2017

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

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

Comment last updated on September 01, 2017 at 14:02 Hours UTC

@topper-123 topper-123 force-pushed the Add_example_to_index.get_loc branch 2 times, most recently from f145027 to f03c140 Compare August 30, 2017 15:58
@topper-123 topper-123 changed the title Added examples to pd.Index.get_loc DOC: Added examples to pd.Index.get_loc Aug 30, 2017
@codecov
Copy link

codecov bot commented Aug 30, 2017

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17380      +/-   ##
==========================================
- Coverage   91.01%   90.99%   -0.02%     
==========================================
  Files         163      163              
  Lines       49570    49570              
==========================================
- Hits        45116    45107       -9     
- Misses       4454     4463       +9
Flag Coverage Δ
#multiple 88.77% <ø> (ø) ⬆️
#single 40.26% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/base.py 95.88% <ø> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.72% <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 77bfe21...f03c140. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 30, 2017

Codecov Report

Merging #17380 into master will decrease coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17380      +/-   ##
==========================================
- Coverage   91.04%   90.99%   -0.05%     
==========================================
  Files         163      163              
  Lines       49581    49581              
==========================================
- Hits        45139    45118      -21     
- Misses       4442     4463      +21
Flag Coverage Δ
#multiple 88.77% <100%> (-0.03%) ⬇️
#single 40.26% <100%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/base.py 95.84% <100%> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/plotting/_converter.py 63.23% <0%> (-1.82%) ⬇️
pandas/core/frame.py 97.72% <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 dad39d5...12ce8d5. Read the comment docs.

@gfyoung gfyoung added Docs Indexing Related to indexing on series/frames, not to indexes themselves labels Aug 30, 2017
>>> unique_index = pd.Index(list('abc'))
>>> unique_index.get_loc('b')
1
>>> monotonic_index = pd.Index(list('abbc'))
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a blank line between cases

@jreback jreback added this to the 0.21.0 milestone Aug 31, 2017
@jreback
Copy link
Contributor

jreback commented Aug 31, 2017

lgtm. ping push / green.

@topper-123 topper-123 force-pushed the Add_example_to_index.get_loc branch from f03c140 to 0f16e2e Compare August 31, 2017 11:15
@topper-123
Copy link
Contributor Author

ping

@topper-123
Copy link
Contributor Author

topper-123 commented Sep 1, 2017

@jreback Is this ok?

(More of a general question): I force-pushed the change, is that ok or is it considered "bad form"?

Edit: I made a last-minute update so sub-class name will displayed properly (e.g. CategoricalIndex).

@topper-123 topper-123 force-pushed the Add_example_to_index.get_loc branch from 21d2a5f to 2c098cd Compare September 1, 2017 14:02
jschendel and others added 8 commits September 1, 2017 09:52
Enabled tests that currently aren't running.  Small fix to make sure all tests pass.  Verified that the raised messages match expectations for TestToDatetimeUnit::test_frame.
* implemented fix for GH issue pandas-dev#16953

* added tests for fix of issue pandas-dev#16953

* changed comments for git issue to pandas style GH#

* changed linelength in tests, so all lines are less than 80 characters

* added whatsnew entry

* swaped conversion and filtering of values, for plot to also work with object dtypes

* refomated code, so len(line) < 80

* changed whatsnew with timedelta and datetime dtypes

* added support for datetimetz and extended tests

* added reason to pytest.mark.xfail
@jreback
Copy link
Contributor

jreback commented Sep 6, 2017

@topper-123 force pushing to your own branch is just fine and in-fact necessary after rebasing.

Examples
---------
>>> unique_index = pd.%(target_klass)s(list('abc'))
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm these are only valid for Index/CategoricalIndex. Do these examples show up for other indexes (IIR we are using this combined doc-string for all sub-classes). You'll have to do this as an additional @Appender to those classes only.

Copy link
Contributor Author

@topper-123 topper-123 Sep 6, 2017

Choose a reason for hiding this comment

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

I think I will do this all over again. Many of the .get_loc methods are subtlely different, so it's difficult to have a common doc-string.

Before I do that, could you please explain how IntervalIndex.get_loc gets its doc-string? From the code it seems it shouldn't have one, but it does....

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I think its inheriting it from Index.get_loc, instead this should use the appender method (guess it was omitted somehow).

jreback and others added 23 commits September 12, 2017 06:26
Mater:

```python
In [1]: import pandas as pd; import numpy as np

In [2]: arr = ['s%04d' % i for i in np.random.randint(0, 500000 // 10,
                                                      size=500000)];
s = pd.Series(arr).astype('category')

In [3]: %timeit s.cat.set_categories(s.cat.categories)
68.5 ms ± 846 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
```

HEAD:

```python
In [1]: import pandas as pd; import numpy as np

In [2]: arr = ['s%04d' % i for i in np.random.randint(0, 500000 // 10,
                                                      size=500000)]
s = pd.Series(arr).astype('category')

In [3]: %timeit s.cat.set_categories(s.cat.categories)
7.43 ms ± 110 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
```

Closes pandas-dev#17508
Ensures index is set when requested during reading of a Stata dta file
Deprecates and renames index to index_col for API consistence

closes pandas-dev#16342
@topper-123
Copy link
Contributor Author

Hi @jreback. I've updated the examples for other index classes as well, but I've messed up the commits, lots of other people's commit are included also.

Should I just delete this branch and make a new pull request?

@jreback
Copy link
Contributor

jreback commented Sep 17, 2017

@topper-123 generally just push (or force push) to the same branch is easiest, but since you did it ok

@jorisvandenbossche jorisvandenbossche modified the milestones: 0.21.0, No action Sep 18, 2017
@topper-123 topper-123 deleted the Add_example_to_index.get_loc branch September 28, 2017 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs Indexing Related to indexing on series/frames, not to indexes themselves

Projects

None yet

Development

Successfully merging this pull request may close these issues.