Skip to content

BUG: Accept column indices for na_values in read_csv #14203

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
gfyoung opened this issue Sep 11, 2016 · 1 comment
Closed

BUG: Accept column indices for na_values in read_csv #14203

gfyoung opened this issue Sep 11, 2016 · 1 comment
Labels
API Design IO CSV read_csv, to_csv
Milestone

Comments

@gfyoung
Copy link
Member

gfyoung commented Sep 11, 2016

>>> from pandas.compat import StringIO
>>> from pandas import read_csv
>>> data = 'a\nfoo\n1'
>>>
>>> read_csv(StringIO(data), na_values={0: 'foo'}, engine='c')
...
TypeError: Expected list, got set
>>> read_csv(StringIO(data), na_values={0: 'foo'}, engine='python')
     a
0  foo  # Should be NaN
1    1

This behaviour is slightly inconsistent with what we do with usecols for example, so it would be nice to be able to process column indices with na_values too.

xref #7119.

@jreback jreback added API Design IO CSV read_csv, to_csv labels Sep 12, 2016
@jreback jreback added this to the Next Major Release milestone Sep 12, 2016
@gfyoung gfyoung changed the title ENH: Accept column indices for na_values in read_csv BUG: Accept column indices for na_values in read_csv Nov 26, 2016
@gfyoung
Copy link
Member Author

gfyoung commented Nov 26, 2016

Reclassifying as a bug because the doc makes it sound like that this behaviour should be possible.

gfyoung added a commit to forking-repos/pandas that referenced this issue Nov 26, 2016
gfyoung added a commit to forking-repos/pandas that referenced this issue Nov 26, 2016
gfyoung added a commit to forking-repos/pandas that referenced this issue Nov 26, 2016
gfyoung added a commit to forking-repos/pandas that referenced this issue Nov 27, 2016
gfyoung added a commit to forking-repos/pandas that referenced this issue Nov 27, 2016
gfyoung added a commit to forking-repos/pandas that referenced this issue Dec 1, 2016
gfyoung added a commit to forking-repos/pandas that referenced this issue Dec 1, 2016
gfyoung added a commit to forking-repos/pandas that referenced this issue Dec 15, 2016
@jreback jreback modified the milestones: 0.19.2, Next Major Release Dec 15, 2016
ischurov pushed a commit to ischurov/pandas that referenced this issue Dec 19, 2016
Patches the following behaviour when `na_values` is passed in as a
dictionary:    1. Prevent aliasing in case `na_values` was defined in
a broader scope.  2. Respect column indices as keys when doing NA
conversions.    Closes pandas-dev#14203.

Author: gfyoung <[email protected]>

Closes pandas-dev#14751 from gfyoung/csv-na-values-patching and squashes the following commits:

cac422c [gfyoung] BUG: Respect column indices for dict-like na_values
1439c27 [gfyoung] BUG: Prevent aliasing of dict na_values
jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this issue Dec 24, 2016
Patches the following behaviour when `na_values` is passed in as a
dictionary:    1. Prevent aliasing in case `na_values` was defined in
a broader scope.  2. Respect column indices as keys when doing NA
conversions.    Closes pandas-dev#14203.

Author: gfyoung <[email protected]>

Closes pandas-dev#14751 from gfyoung/csv-na-values-patching and squashes the following commits:

cac422c [gfyoung] BUG: Respect column indices for dict-like na_values
1439c27 [gfyoung] BUG: Prevent aliasing of dict na_values

(cherry picked from commit dd8cba2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design IO CSV read_csv, to_csv
Projects
None yet
Development

No branches or pull requests

2 participants