Skip to content

ERR: improves message raised for bad names in usecols (GH14154) #14163

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

Closed
wants to merge 1 commit into from
Closed

ERR: improves message raised for bad names in usecols (GH14154) #14163

wants to merge 1 commit into from

Conversation

aechase
Copy link
Contributor

@aechase aechase commented Sep 6, 2016

@jorisvandenbossche jorisvandenbossche added Error Reporting Incorrect or improved errors from pandas IO CSV read_csv, to_csv labels Sep 6, 2016
@codecov-io
Copy link

Current coverage is 85.24% (diff: 53.84%)

Merging #14163 into master will decrease coverage by <.01%

@@             master     #14163   diff @@
==========================================
  Files           139        139          
  Lines         50502      50502          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          43055      43051     -4   
- Misses         7447       7451     +4   
  Partials          0          0          

Powered by Codecov. Last update e54d4db...1a34b2a

raise ValueError("Usecols do not match names.")
bad_cols = [n for n in self.usecols if n not in self.names]
if len(bad_cols) > 0:
raise ValueError(("%s specified in usecols but not found "
Copy link
Contributor

Choose a reason for hiding this comment

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

use .format()

Copy link
Contributor

Choose a reason for hiding this comment

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

you prob also need a ','.join(bad_cols), need a test for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jreback I'm trying to get the following test to work:

msg = ("c, d specified in usecols but not found in names.")
with tm.assertRaisesRegexp(ValueError, msg):
    self.read_csv(StringIO(data), names=['a', 'b'], usecols=['c', 'd'], header=None)

Currently this test fails because two exceptions are being raised: one by parsers.py, which produces the expected message; and one by parser.pyx, which produces a different message. But, when I try to play with this in my interpreter, I only get the first, expected, ValueError message. Where does the parser.pyxexception get raised to? Is it necessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's possible we need to put this checking earlier

@jorisvandenbossche
Copy link
Member

@aechase Do you have time to update this?

@aechase
Copy link
Contributor Author

aechase commented Nov 3, 2016

@jorisvandenbossche I'll take another look at it next week. I discovered that this error message gets raised in several (redundant) places, which made it a more complex issue than I originally had time for.

@jreback
Copy link
Contributor

jreback commented Dec 6, 2016

we just updated some usecols functionaility, so if you could rebase would be great.

@jreback
Copy link
Contributor

jreback commented Dec 30, 2016

can you rebase

@aechase
Copy link
Contributor Author

aechase commented Jan 4, 2017

@jreback I'm afraid I'm not going to have time to look at this for at least a couple of weeks.

@jreback
Copy link
Contributor

jreback commented Feb 27, 2017

closing as stale. please ping if you'd like to continue.

@jreback jreback closed this Feb 27, 2017
@jreback jreback added this to the No action milestone Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants