BUG: Don't error with empty Series for .isin
State: closed

Empty `Series` initializes to `float64`, even when the data type is `object` for `.isin`, leading to an error with membership.

Closes #16991.

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

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17006?src=pr&el=h1) Report
> Merging [#17006](https://codecov.io/gh/pandas-dev/pandas/pull/17006?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/fcb0263762a31724ba6db39bf1564569dda068a0?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/17006/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/17006?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #17006      +/-   ##
==========================================
+ Coverage   90.99%      91%   +<.01%     
==========================================
  Files         161      161              
  Lines       49291    49293       +2     
==========================================
+ Hits        44852    44857       +5     
+ Misses       4439     4436       -3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.77% <100%> (+0.02%)` | :arrow_up: |
| #single | `40.18% <100%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17006?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/algorithms.py](https://codecov.io/gh/pandas-dev/pandas/pull/17006?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYWxnb3JpdGhtcy5weQ==) | `94.43% <100%> (+0.01%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17006?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17006?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.76% <0%> (-0.1%)` | :arrow_down: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/17006?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `65.05% <0%> (+1.81%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17006?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/17006?src=pr&el=footer). Last update [fcb0263...c2cec77](https://codecov.io/gh/pandas-dev/pandas/pull/17006?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

ok merge away

FYI you would think the checks are O(1) but the current impl is not great and repeated calling or misordering of the checks can cause a lot of drag
> FYI you would think the checks are O(1) but the current impl is not great and repeated calling or misordering of the checks can cause a lot of drag

Ah, that's fair.  I will keep my eye out for this and will readdress if other people experience a significant degradation in someway that isn't addressed by the tests.