BUG: Better handle larger numbers in to_numeric
State: closed

Fun edge case bug fixes for `to_numeric`:

* Warn about lossiness when passing really large numbers that exceed `(u)int64` ranges.

* Coerce negative numbers to float when requested instead of crashing and returning `object`.

* Consistently parse numbers as integers / floats, even if we know that the resulting container has to be float. This is to ensure consistent error behavior when inputs numbers are too large.

Closes #24910.


Labels:
name: Bug
name: Dtype Conversions
description: Unexpected or buggy dtype conversions
name: Numeric Operations
description: Arithmetic, Comparison, and Logical operations

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24956?src=pr&el=h1) Report
> Merging [#24956](https://codecov.io/gh/pandas-dev/pandas/pull/24956?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/95f8dca47723192ddeed5a2f198d0521c687c9aa?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #24956      +/-   ##
==========================================
+ Coverage   92.38%   92.38%   +<.01%     
==========================================
  Files         166      166              
  Lines       52398    52398              
==========================================
+ Hits        48406    48407       +1     
+ Misses       3992     3991       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.8% <ø> (ø)` | :arrow_up: |
| #single | `42.88% <ø> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24956?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/tools/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/24956/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdG9vbHMvbnVtZXJpYy5weQ==) | `100% <ø> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24956/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.13% <0%> (+0.09%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24956?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/24956?src=pr&el=footer). Last update [95f8dca...56b6921](https://codecov.io/gh/pandas-dev/pandas/pull/24956?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/24956?src=pr&el=h1) Report
> Merging [#24956](https://codecov.io/gh/pandas-dev/pandas/pull/24956?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/95f8dca47723192ddeed5a2f198d0521c687c9aa?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #24956   +/-   ##
=======================================
  Coverage   92.38%   92.38%           
=======================================
  Files         166      166           
  Lines       52398    52398           
=======================================
  Hits        48406    48406           
  Misses       3992     3992
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.8% <ø> (ø)` | :arrow_up: |
| #single | `42.89% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24956?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/tools/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/24956/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdG9vbHMvbnVtZXJpYy5weQ==) | `100% <ø> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24956?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/24956?src=pr&el=footer). Last update [95f8dca...56b6921](https://codecov.io/gh/pandas-dev/pandas/pull/24956?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/24956?src=pr&el=h1) Report
> Merging [#24956](https://codecov.io/gh/pandas-dev/pandas/pull/24956?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/515b0fa77e788c7fc15c9966e502ee99585fed39?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #24956   +/-   ##
=======================================
  Coverage   92.38%   92.38%           
=======================================
  Files         166      166           
  Lines       52401    52401           
=======================================
  Hits        48410    48410           
  Misses       3991     3991
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.8% <ø> (ø)` | :arrow_up: |
| #single | `42.87% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24956?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/tools/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/24956/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdG9vbHMvbnVtZXJpYy5weQ==) | `100% <ø> (ø)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/24956/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.92% <0%> (ø)` | :arrow_up: |

------

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

@jreback : Addressed all comments, and all is still green.  PTAL.
thanks @gfyoung