ENH: ExtensionArray.searchsorted
Hello @TomAugspurger! Thanks for updating the PR.















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

##### Comment last updated on December 28, 2018 at 19:54 Hours UTC # [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24350?src=pr&el=h1) Report
> Merging [#24350](https://codecov.io/gh/pandas-dev/pandas/pull/24350?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/c230f297c279bcac536f4689a30f1894d0278d06?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #24350      +/-   ##
==========================================
+ Coverage   92.29%   92.29%   +<.01%     
==========================================
  Files         162      162              
  Lines       51806    51816      +10     
==========================================
+ Hits        47815    47825      +10     
  Misses       3991     3991
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.7% <100%> (ø)` | :arrow_up: |
| #single | `42.99% <20%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24350?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/24350/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `97.46% <100%> (+0.04%)` | :arrow_up: |
| [pandas/core/arrays/sparse.py](https://codecov.io/gh/pandas-dev/pandas/pull/24350/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3NwYXJzZS5weQ==) | `92.15% <100%> (+0.06%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24350?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/24350?src=pr&el=footer). Last update [c230f29...58418ab](https://codecov.io/gh/pandas-dev/pandas/pull/24350?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/24350?src=pr&el=h1) Report
> Merging [#24350](https://codecov.io/gh/pandas-dev/pandas/pull/24350?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d1b2a52a59b11bd66458289920612b88d80cab73?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #24350      +/-   ##
==========================================
- Coverage    92.3%    92.3%   -0.01%     
==========================================
  Files         165      165              
  Lines       52176    52186      +10     
==========================================
+ Hits        48161    48170       +9     
- Misses       4015     4016       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.72% <100%> (ø)` | :arrow_up: |
| #single | `42.96% <27.27%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24350?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/24350/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `98.23% <100%> (+0.03%)` | :arrow_up: |
| [pandas/core/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/24350/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYmFzZS5weQ==) | `97.7% <100%> (ø)` | :arrow_up: |
| [pandas/core/arrays/sparse.py](https://codecov.io/gh/pandas-dev/pandas/pull/24350/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3NwYXJzZS5weQ==) | `92.17% <100%> (+0.06%)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24350/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.75% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24350?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/24350?src=pr&el=footer). Last update [d1b2a52...a91fcec](https://codecov.io/gh/pandas-dev/pandas/pull/24350?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 Hmm, I'm not sure what to do then. ExtensionArrays are more at the level of
an ndarray than a Series.

@shoyer, if I were writing an ExtensionArray that also wanted to implement
`__array_function__`, is it OK for the name of positional arguments to
differ?

On Thu, Dec 20, 2018 at 12:05 PM topper-123 <notifications@github.com>
wrote:

> *@topper-123* commented on this pull request.
> ------------------------------
>
> In pandas/core/arrays/base.py
> <https://github.com/pandas-dev/pandas/pull/24350#discussion_r243366588>:
>
> > @@ -505,6 +506,54 @@ def unique(self):
>
>          uniques = unique(self.astype(object))
>
>          return self._from_sequence(uniques, dtype=self.dtype)
>
>
>
> +    def searchsorted(self, v, side="left", sorter=None):
>
>
> Sorry, meant value, as that is the name used in Series.searchsorted and
> various other searchsorted implementations in pandas (
> Categorical.searchsorted at least, haven’t checked all impl.).
>
> I think it`s inconsistent to follow numpy naming here, when pandas’s is
> better:-)
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/24350#discussion_r243366588>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIsqBJDEwwMDdqbdFzQEupGtUfVF7ks5u69GFgaJpZM4ZaO7Y>
> .
>
 > if I were writing an ExtensionArray that also wanted to implement `__array_function__`, is it OK for the name of positional arguments to differ?

`__array_function__` passes on the exact positional and keyword argument from how the function is called. So in practice this would mean that anyone who uses keyword arguments with NumPy's names would get a TypeError, unless you add keyword-only arguments for NumPy's names, too. Using positional arguments would be fine, though. Thanks. Given that, it's probably best to follow NumPy's signature exactly
wherever possible.

On Thu, Dec 20, 2018 at 1:01 PM Stephan Hoyer <notifications@github.com>
wrote:

> if I were writing an ExtensionArray that also wanted to implement
> __array_function__, is it OK for the name of positional arguments to
> differ?
>
> __array_function__ passes on the exact positional and keyword argument
> from how the function is called. So in practice this would mean that anyone
> who uses keyword arguments with NumPy's names would get a TypeError, unless
> you add keyword-only arguments for NumPy's names, too. Using positional
> arguments would be fine, though.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/24350#issuecomment-449101653>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIk9xLOo3D-VHj7MD8IcGKlWNfp31ks5u695ygaJpZM4ZaO7Y>
> .
>
 Changed `v` to value. thanks @TomAugspurger  Yes (for developers). I'm hoping to do that later today.

On Fri, Dec 28, 2018 at 3:15 PM Jeff Reback <notifications@github.com>
wrote:

> *@jreback* commented on this pull request.
> ------------------------------
>
> In pandas/core/arrays/base.py
> <https://github.com/pandas-dev/pandas/pull/24350#discussion_r244409154>:
>
> > +        Returns
> +        -------
> +        indices : array of ints
> +            Array of insertion points with the same shape as `value`.
> +
> +        See Also
> +        --------
> +        numpy.searchsorted : Similar method from NumPy.
> +        """
> +        # Note: the base tests provided by pandas only test the basics.
> +        # We do not test
> +        # 1. Values outside the range of the `data_for_sorting` fixture
> +        # 2. Values between the values in the `data_for_sorting` fixture
> +        # 3. Missing values.
> +        arr = self.astype(object)
> +        return arr.searchsorted(value, side=side, sorter=sorter)
>
> IIRC you have an issue to show a warning here for EA's that don't
> redefined this I think?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/24350#pullrequestreview-188370565>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHInoAr2DXOO0ZNBQDm03hhR6q3aSrks5u9onegaJpZM4ZaO7Y>
> .
>
