Skip to content

DOC: show failing string on numeric parse #13773

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 4 commits into from
Jul 26, 2016

Conversation

chris-b1
Copy link
Contributor

@chris-b1 chris-b1 commented Jul 24, 2016

# before
In [7]: pd.to_numeric(['a'])
ValueError: Unable to parse string

# after
In [1]: pd.to_numeric(['a'])
ValueError: Unable to parse string "a" at position 0

@jreback
Copy link
Contributor

jreback commented Jul 24, 2016

I think its straightforward to also provide a row/line number here, e.g. i which we know already

@jreback jreback added IO Data IO issues that don't fit into a more specific label Compat pandas objects compatability with Numpy or Python functions labels Jul 24, 2016
if not coerce_numeric:
raise
raise type(e)(e.message + ' in row {}'.format(i))
Copy link
Contributor

Choose a reason for hiding this comment

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

acutally maybe row is not the word, these are 1-d arrays, so maybe entry? value at index i?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry to do a bit purist, but 'array index' sounds also a bit strange when you pass a Series and not an array. And given that just 'at index' can be confused with the actual index labels, maybe just 'at position ..' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I do think that's better.

@codecov-io
Copy link

codecov-io commented Jul 26, 2016

Current coverage is 85.23% (diff: 100%)

No coverage report found for master at 6efd743.

Powered by Codecov. Last update 6efd743...13bfd11

@jorisvandenbossche jorisvandenbossche added this to the 0.19.0 milestone Jul 26, 2016
@jorisvandenbossche jorisvandenbossche added the Error Reporting Incorrect or improved errors from pandas label Jul 26, 2016
@chris-b1
Copy link
Contributor Author

@jorisvandenbossche - I think this one is good now.

@jorisvandenbossche jorisvandenbossche merged commit 8f64ad7 into pandas-dev:master Jul 26, 2016
@jorisvandenbossche
Copy link
Member

Thanks!

@chris-b1 chris-b1 deleted the numeric-error branch July 29, 2016 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Error Reporting Incorrect or improved errors from pandas IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants