ENH/TST/DOC: set infer_nrows for read_fwf (GH15138)
State: closed

- [ ] closes #15138
- [ ] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

`read_fwf` can infer the widths of columns of a dataset from a file or buffer, but if the widths change after the first 100 rows, then the default behavior fails to capture the data correctly. This PR addresses that issue by allowing the user to set a parameter `infer_nrows` that is passed down to the appropriate function.

The associated test ensures that `colspecs` can be determined from the first row, thereby missing data from the subsequent rows and verifying the expected behavior.

Labels:
name: IO Data
description: IO issues that don't fit into a more specific label
name: IO CSV
description: read_csv, to_csv

Comments:
Hello @rdmontgomery! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/io/parsers.py`](https://github.com/rdmontgomery/pandas/blob/da081a868c403ed42ad754adc32333e36bdf06cd/pandas/io/parsers.py) !

 - There are no PEP8 issues in the file [`pandas/tests/io/parser/test_read_fwf.py`](https://github.com/rdmontgomery/pandas/blob/da081a868c403ed42ad754adc32333e36bdf06cd/pandas/tests/io/parser/test_read_fwf.py) !


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

```diff
@@            Coverage Diff             @@
##           master   #23238      +/-   ##
==========================================
+ Coverage   92.29%   92.29%   +<.01%     
==========================================
  Files         161      161              
  Lines       51498    51500       +2     
==========================================
+ Hits        47530    47533       +3     
+ Misses       3968     3967       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.69% <100%> (ø)` | :arrow_up: |
| #single | `42.42% <44.44%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23238?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/parsers.py](https://codecov.io/gh/pandas-dev/pandas/pull/23238/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhcnNlcnMucHk=) | `95.36% <100%> (+0.06%)` | :arrow_up: |

------

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

Hi @WillAyd, thanks for reviewing my code. I made the requested changes and it looks like everything passed now. Is there anything else I can do for this?
Thanks, guys. I appreciate your help in moving this forward.

I'm not sure what happened with the CircleCI build this time around. Looks like maybe debian.org was having temporary troubles. Any advice here?
> Err:3 http://deb.debian.org/debian stretch Release
>  404  Not Found
Hi @jreback and @WillAyd, can you help me understand why the CircleCI test failed? I'd like to re-run the test without pushing any code changes, but I haven't been able to figure out how.
looks suprious. merge master and push again.
@rdmontgomery can you merge master. @WillAyd if you have any comments.
@rdmontgomery would be curious if you have thoughts on my previous comment. Always good to simplify / cleanup internal code if possible
pls merge master as well
rebased.
@rdmontgomery can you address last comment around the re-ordering of the internal function signature? Once that is done I'm OK to approve and merge
> 
> 
> @rdmontgomery can you address last comment around the re-ordering of the internal function signature? Once that is done I'm OK to approve and merge

I'll jump on it tomorrow morning! I've been in the last negotiations of a job offer and I just wrapped that up today. I've got some time again!
Thanks @rdmontgomery !

Good luck with the job