pandas icon indicating copy to clipboard operation
pandas copied to clipboard

dataframe.astype() exception message to include column name

Open dannyi96 opened this issue 3 years ago • 1 comments

  • [X] closes #47571(Replace xxxx with the Github issue number)
  • [x] Tests added and passed if fixing a bug or adding a new feature
  • [x] All code checks passed.
  • [X] Added type annotations to new arguments/methods/functions.
  • [ ] Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Description: Added column related info as part of astype exceptions

Code Old Error New Error
pd.DataFrame({'a':[1,2,"text"], 'b':[1,2,3]}).astype({'a': int}) ValueError: invalid literal for int() with base 10: 'text' ValueError: Error during type conversion for column a: invalid literal for int() with base 10: 'text'

dannyi96 avatar Aug 30 '22 22:08 dannyi96

thanks for the review @phofl @mroeschke sure @phofl, will update the PR with changes

dannyi96 avatar Sep 18 '22 13:09 dannyi96

Hi @mroeschke , had missed following up on this PR. feel free to let me know if any changes are required here (or) if we should hold this PR for the time being.

Thanks in advance :)

dannyi96 avatar Oct 10 '22 14:10 dannyi96

Thanks @dannyi96

mroeschke avatar Oct 14 '22 17:10 mroeschke