Read from HDF with empty `where` throws an error
State: closed

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


Labels:
name: API Design
name: IO HDF5
description: read_hdf, HDFStore

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26746?src=pr&el=h1) Report
> Merging [#26746](https://codecov.io/gh/pandas-dev/pandas/pull/26746?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/c7748ca057cad4a80a6c4cbf8b49c5d9f3e7ea1c?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

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

```diff
@@           Coverage Diff           @@
##           master   #26746   +/-   ##
=======================================
  Coverage    91.7%    91.7%           
=======================================
  Files         179      179           
  Lines       50767    50767           
=======================================
  Hits        46555    46555           
  Misses       4212     4212
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.29% <50%> (ø)` | :arrow_up: |
| #single | `41.21% <100%> (-0.08%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26746?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/26746/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3B5dGFibGVzLnB5) | `90.29% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26746/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26746/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.88% <0%> (-0.12%)` | :arrow_down: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/26746/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.93% <0%> (+0.21%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26746?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/26746?src=pr&el=footer). Last update [c7748ca...f75ae8c](https://codecov.io/gh/pandas-dev/pandas/pull/26746?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/26746?src=pr&el=h1) Report
> Merging [#26746](https://codecov.io/gh/pandas-dev/pandas/pull/26746?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/13023c6515ca11a3353d98645f48a403243101cf?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/26746/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26746?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26746      +/-   ##
==========================================
- Coverage   91.71%   91.71%   -0.01%     
==========================================
  Files         178      178              
  Lines       50776    50776              
==========================================
- Hits        46571    46567       -4     
- Misses       4205     4209       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.3% <100%> (ø)` | :arrow_up: |
| #single | `41.19% <100%> (-0.08%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26746?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/26746/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3B5dGFibGVzLnB5) | `90.29% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26746/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26746/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.88% <0%> (-0.12%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26746/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.84% <0%> (-0.11%)` | :arrow_down: |
| [pandas/core/computation/expr.py](https://codecov.io/gh/pandas-dev/pandas/pull/26746/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vZXhwci5weQ==) | `97.8% <0%> (+0.27%)` | :arrow_up: |

------

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

`return where if len(where) else None` fails when `where is None`. 
In one of the tests the `where` is assigned as `Int64Index` directly. Is it designed to (have not found any info on that in manual or API reference)? If so - in case of empty `Index` the desired result should be empty `df` (well I suppose; now it's just an error too btw). So it differs from empty list (i.e. list of terms) where desired output will be unfiltered = full `df`. And this difference should be processed somehow in `_ensure_term`.

Besides I'm confused with type checking - now `where` allows all the `abc.iterable` (almost): `isinstance(w, (Expr, string_types)) or is_list_like(w)`. But at the same time inside `_ensure_term` only `isinstance(where, (list, tuple))` are processed. Other iterables are just passed as is (one may pass `range(3)`, `[1,2,3]`, `pd.Series` etc.). So - is it intentionally or (as I understand from the API reference  - "list of Term (or convertible) objects, optional" - i.e. it is supposed to be an iterable of __terms__) all `is_list_like`should be hooked inside `_ensure_term` too? E.g. instead of `isinstance(where, (list, tuple))` should be `is_list_like(where)`?
lgtm. can you merge master and ping on green.
> lgtm. can you merge master and ping on green.

I'm sorry - what is "ping on green"?
Besides what about type checking (in my questions) - leave it as is? Then, for example, if `where = pd.Index([])` - the whole df will be returned as for the empty list. 
> > lgtm. can you merge master and ping on green.
> 
> I'm sorry - what is "ping on green"?
> Besides what about type checking (in my questions) - leave it as is? Then, for example, if `where = pd.Index([])` - the whole df will be returned as for the empty list.

ping on green - when the CI is green

where=‘’ is the same as where=None so yes return the entire frame
@jreback all is green.
thanks @BeforeFlight