Speed up checking for NaN for floats
State: closed

- [x] closes N/A
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

This isn't giving much speedup because this is simple change, but for some certain inputs like empty datetime fields in csv it gives some speed (because empty fields are parsed as float `NaN`-s).

Labels:
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
name: Performance
description: Memory or execution speed performance

Comments:
Here's what `asv continuous -f 1.01 upstream/master float-nat-speedup -e -b io.csv -a sample_time=1 -a warmup_time=1` shows:

before|after|ratio|test name
-|-|-|-
[c7c4c943]|[54533f3b]||
**master**|**float-nat-speedup**||
1.91±0.03ms|1.86±0.01ms|0.97|io.csv.ReadCSVParseDates.time_multiple_date

I'm run more thorough benchmark now.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25946?src=pr&el=h1) Report
> Merging [#25946](https://codecov.io/gh/pandas-dev/pandas/pull/25946?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/c7c4c94389103c017e950b37191d7c267a75fa22?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #25946      +/-   ##
==========================================
- Coverage   91.82%   91.81%   -0.01%     
==========================================
  Files         175      175              
  Lines       52581    52581              
==========================================
- Hits        48280    48276       -4     
- Misses       4301     4305       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.36% <ø> (ø)` | :arrow_up: |
| #single | `41.89% <ø> (-0.08%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25946?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/25946/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `75% <0%> (-12.5%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/25946/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.79% <0%> (-0.12%)` | :arrow_down: |

------

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

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

```diff
@@            Coverage Diff             @@
##           master   #25946      +/-   ##
==========================================
- Coverage   91.82%   91.81%   -0.01%     
==========================================
  Files         175      175              
  Lines       52581    52581              
==========================================
- Hits        48280    48276       -4     
- Misses       4301     4305       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.36% <ø> (ø)` | :arrow_up: |
| #single | `41.89% <ø> (-0.08%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25946?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/25946/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `75% <0%> (-12.5%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/25946/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.79% <0%> (-0.12%)` | :arrow_down: |

------

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

can you run the benchmarks for missing value checking and see what the change is.
Sure, I am already running those, but it takes _huuuuge_ time to run when you set warmup and sampling times high enough (and with default settings the results are too flaky to be believable).
> Sure, I am already running those, but it takes huuuuge time to run when you set warmup and sampling times high enough (and with default settings the results are too flaky to be believable).

right, though just the missing ones shouldn't be that huge
Can you point out these "missing" benchmark names?
you can pass a regex to select a subset
Could you please recommend what benchmark names might be relevant? I didn't study the whole list of them yet...
So running this `asv continuous -f 1.01 upstream/master float-nat-speedup -b '.*missing.*' -b io.csv -e -a sample_time=2 -a warmup_time=2` produces:

before|after|ratio|test name
-|-|-|-
[c7c4c943]|[6e77c81f]||
**master**|**float-nat-speedup**||
1.48±0.01μs|1.40±0.03μs|0.95|timedelta.TimedeltaConstructor.time_from_missing
8.41±0.09ms|7.79±0.06ms|0.93|io.csv.ReadCSVSkipRows.time_skipprows(10000)

I'm sure this is not benchmarking the worst case, as I think it should speed up parsing a date column where most fields are empty, but only after #25754 is merged so that `NaN`-s (to which empty fields are translated) stay as floats instead of literal "nan" strings.
thanks @vnlitvin