Pass the errors and kwargs arguments through to astype in the columns…
State: closed

… dict logic branch.


Labels:
name: Error Reporting
description: Incorrect or improved errors from pandas
name: DataFrame
description: DataFrame data structure

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

```diff
@@            Coverage Diff             @@
##           master   #25888      +/-   ##
==========================================
+ Coverage   91.47%   91.48%   +<.01%     
==========================================
  Files         175      175              
  Lines       52885    52885              
==========================================
+ Hits        48379    48380       +1     
+ Misses       4506     4505       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.04% <100%> (ø)` | :arrow_up: |
| #single | `41.82% <0%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25888?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `93.54% <100%> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `89.84% <0%> (+0.1%)` | :arrow_up: |

------

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

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

```diff
@@            Coverage Diff             @@
##           master   #25888      +/-   ##
==========================================
+ Coverage   91.47%   91.81%   +0.33%     
==========================================
  Files         175      175              
  Lines       52885    52580     -305     
==========================================
- Hits        48379    48274     -105     
+ Misses       4506     4306     -200
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.36% <ø> (+0.32%)` | :arrow_up: |
| #single | `41.9% <ø> (+0.07%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25888?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `93.54% <ø> (ø)` | :arrow_up: |
| [pandas/compat/pickle\_compat.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9waWNrbGVfY29tcGF0LnB5) | `69.13% <0%> (-6.48%)` | :arrow_down: |
| [pandas/plotting/\_compat.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb21wYXQucHk=) | `83.33% <0%> (-4.17%)` | :arrow_down: |
| [pandas/core/config\_init.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29uZmlnX2luaXQucHk=) | `96.96% <0%> (-2.24%)` | :arrow_down: |
| [pandas/plotting/\_style.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19zdHlsZS5weQ==) | `77.17% <0%> (-0.49%)` | :arrow_down: |
| [pandas/compat/numpy/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9udW1weS9fX2luaXRfXy5weQ==) | `92.85% <0%> (-0.48%)` | :arrow_down: |
| [pandas/core/groupby/grouper.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGVyLnB5) | `98.16% <0%> (-0.37%)` | :arrow_down: |
| [pandas/plotting/\_misc.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19taXNjLnB5) | `38.46% <0%> (-0.23%)` | :arrow_down: |
| [pandas/core/computation/engines.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vZW5naW5lcy5weQ==) | `88.52% <0%> (-0.19%)` | :arrow_down: |
| [pandas/plotting/\_timeseries.py](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL190aW1lc2VyaWVzLnB5) | `65.28% <0%> (-0.18%)` | :arrow_down: |
| ... and [76 more](https://codecov.io/gh/pandas-dev/pandas/pull/25888/diff?src=pr&el=tree-more) | |

------

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

what exactly are you trying to do? does this close an issue? always always need a test
If you look at lines 5705 [0], 5732 [1] the calls to `astype` pass through the `errors` arg and `kwargs`. Only when the column names are passed as a dict are you not allowed to set the errors behavior.

How I ran into this was when I am calling astype on one column I can set errors='coerce' but when I am calling `astype` on a dict of columns this does not work. 

I was hoping to get feedback on this approach.

[0] https://github.com/pandas-dev/pandas/pull/25888/files#diff-03b380f521c43cf003207b0711bac67fR5705
[1] https://github.com/pandas-dev/pandas/pull/25888/files#diff-03b380f521c43cf003207b0711bac67fR5732

you would be better off to write a test that shows the behavior
writing the code to latch is generally pretty easy once you have good reproducing tests
Updated with the test @jreback .   Side note is that I was tempted to rename `Generic` to `TestGeneric` but I refrained. :)
The whatsnew note is added in 0430b38fe3733c5f5a50489a758c8268d140dc6d
Anything more I need to pursue on this?
Hello @johnklehm! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:





There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2019-03-31 00:32:36 UTC
PEP8 E241 is normally off by default along with E226 E242....is the pep8speaks bot implying E241 is adhered to for pandas?
@johnklehm yep also need to fix up flake8 errors
I see 2 flake8 errors but don't think they're related to my changes:
```19:53 $ flake8
./build/lib.linux-x86_64-3.7/pandas/_version.py:10:1: F401 'sys' imported but unused
./build/lib.linux-x86_64-3.7/pandas/tests/generic/test_generic.py:207:5: E303 too many blank lines (3)
```
thanks @johnklehm