Skip to content

dataframe.astype() exception message to include column name #48321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 14, 2022

Conversation

dannyi96
Copy link
Contributor

@dannyi96 dannyi96 commented Aug 30, 2022

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: invalid literal for int() with base 10: 'text': Error while type casting for column 'a'

@dannyi96 dannyi96 marked this pull request as ready for review August 31, 2022 16:37
@mroeschke mroeschke added Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas labels Sep 1, 2022
Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you address review comments? Also we need a whatsnew

@dannyi96
Copy link
Contributor Author

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

@dannyi96 dannyi96 marked this pull request as draft September 18, 2022 13:43
@dannyi96 dannyi96 marked this pull request as ready for review September 25, 2022 11:00
@dannyi96 dannyi96 requested review from mroeschke and phofl and removed request for mroeschke and phofl September 25, 2022 15:22
@dannyi96
Copy link
Contributor Author

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 :)

@mroeschke mroeschke added this to the 2.0 milestone Oct 14, 2022
@mroeschke mroeschke merged commit 7751108 into pandas-dev:main Oct 14, 2022
@mroeschke
Copy link
Member

Thanks @dannyi96

@dannyi96 dannyi96 deleted the astype_err_impr branch October 14, 2022 17:22
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
…ev#48321)

* dataframe.astype() exception message to include column name

* added testcase

* review comments

* review comments

* review comments

* review comments

* Update doc/source/whatsnew/v1.6.0.rst

Co-authored-by: Matthew Roeschke <[email protected]>

* dataframe.astype() exception message to include column name

Co-authored-by: Matthew Roeschke <[email protected]>
Co-authored-by: Patrick Hoefler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: dataframe.astype() exception message to include column name
3 participants