DEPR: deprecate .select()
State: closed

xref #12401


Labels:
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves
name: API Design

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=h1) Report
> Merging [#17633](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/e6d8953f8cd5ad9f22894a8948e9b6340ad819f4?src=pr&el=desc) will **decrease** coverage by `0.04%`.
> The diff coverage is `84.53%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/17633/graphs/tree.svg?src=pr&width=650&token=eZ4WkYLtcO&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #17633      +/-   ##
==========================================
- Coverage   91.22%   91.18%   -0.05%     
==========================================
  Files         163      163              
  Lines       49652    49709      +57     
==========================================
+ Hits        45294    45326      +32     
- Misses       4358     4383      +25
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.97% <84.53%> (-0.02%)` | :arrow_down: |
| #single | `40.16% <41.23%> (-0.08%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `91.96% <100%> (-0.03%)` | :arrow_down: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `91.13% <76.47%> (-0.86%)` | :arrow_down: |
| [pandas/core/indexing.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhpbmcucHk=) | `93.13% <83.07%> (-0.81%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.77% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=footer). Last update [e6d8953...1581a05](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=h1) Report
> Merging [#17633](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/69024a0110fdc5d8e8a015ea2c5316826e2f80be?src=pr&el=desc) will **decrease** coverage by `0.03%`.
> The diff coverage is `82.89%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/17633/graphs/tree.svg?height=150&width=650&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #17633      +/-   ##
==========================================
- Coverage   91.26%   91.22%   -0.04%     
==========================================
  Files         163      163              
  Lines       49869    49916      +47     
==========================================
+ Hits        45511    45535      +24     
- Misses       4358     4381      +23
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.02% <82.89%> (-0.02%)` | :arrow_down: |
| #single | `40.24% <48.68%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `91.42% <ø> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `92.1% <100%> (-0.03%)` | :arrow_down: |
| [pandas/core/indexing.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhpbmcucHk=) | `93% <79.68%> (-0.98%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.73% <0%> (-0.1%)` | :arrow_down: |
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `96.07% <0%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=footer). Last update [69024a0...ef031c1](https://codecov.io/gh/pandas-dev/pandas/pull/17633?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

I personally don't think we should recommend `.loc(axis=..)[]`. Why not just `df.loc[]` (or `df.loc[:, ..]` for axis=1) ?
> I personally don't think we should recommend .loc(axis=..)[]. Why not just df.loc[] (or df.loc[:, ..] for axis=1) ?

those work, its an option though
Hello @jreback! Thanks for updating the PR.



















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

##### Comment last updated on October 03, 2017 at 20:10 Hours UTC
> I also don't think it is really needed for deprecating select? It only means that the alternative will be a bit more convoluted.

Well, we already have this ability to accept pretty arbitrary things for ``.loc`` callables. The alternative is basically to deprecate ``.select()`` and NOT offer any alternatives directly. Which is for sure simpler. This way it still 'works'.

and yes its needed for our current tests to pass. Yes its pretty fragile. I think removing this logic and simply deprecating ``.select`` entirely is an option.

> Well, we already have this ability to accept pretty arbitrary things for .loc callables.

It is not arbitrary, it is the calling object (series of frame). Which is clearly different from the index elements.

> Yes its pretty fragile. I think removing this logic and simply deprecating .select entirely is an option.

I would personally go for that, instead of adding this fragile logic


There are still 'alternatives' to offer, although a bit more work to type. Eg:

```
s.loc[s.index.map(f).values]
```

it's only a bit annoying that you need the `.values` (and there are maybe others I don't think of)

We could also add the 'function' ability to `filter` ..
ok will revise tomorrow
@jorisvandenbossche updated, MUCH simpler.
any final comments
updated, any final comments?
its useful to have ``maybe_callable`` actually know that it has an axis. It should have originally been done like this.
But it is *not used* by the callable. Can you please try to explain to me *why* you want it there? And "it is useful" is not clarifying
ok I took the axis bizness out. should be good to go now.
Thanks @jreback !