BUG: Allow value labels to be read with iterator
State: closed

All value labels to be read before the iterator has been used
Fix issue where categorical data was incorrectly reformatted when
write_index was False

closes #16923

 - [X] closes #16923
 - [X] tests added / passed
 - [X] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff`` (On Windows, ``git diff upstream/master -u -- "*.py" | flake8 --diff`` might work as an alternative.)
 - [X] whatsnew entry


Labels:
name: Bug
name: IO Stata
description: read_stata, to_stata

Comments:
@gfyoung just an FYI. I don't set the version until right before merging (or done, just waiting for a final fix). This prevents stale PR's being tagged. (in this case it is fine though)
> just an FYI. I don't set the version until right before merging

That's fair.  I figured this PR would be merged for this release, so I tagged it.
> That's fair. I figured this PR would be merged for this release, so I tagged it.

yep in this case totally good.
lgtm. ping on green.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16926?src=pr&el=h1) Report
> Merging [#16926](https://codecov.io/gh/pandas-dev/pandas/pull/16926?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/a587d568d213c62307a72d98d6913239f55844e8?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `92.85%`.

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

```diff
@@            Coverage Diff             @@
##           master   #16926      +/-   ##
==========================================
- Coverage   90.99%   90.98%   -0.02%     
==========================================
  Files         161      161              
  Lines       49303    49306       +3     
==========================================
- Hits        44863    44859       -4     
- Misses       4440     4447       +7
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.75% <92.85%> (ø)` | :arrow_up: |
| #single | `40.19% <7.14%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16926?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/stata.py](https://codecov.io/gh/pandas-dev/pandas/pull/16926?src=pr&el=tree#diff-cGFuZGFzL2lvL3N0YXRhLnB5) | `93.66% <92.85%> (+0.19%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/16926?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16926?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.71% <0%> (-0.1%)` | :arrow_down: |

------

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

@jreback green
Thanks @bashtage !