BUG: Accept column indices for na_values in read_csv #14203

Closed
gfyoung opened this Issue Sep 11, 2016 · 1 comment

Comments

Projects
None yet
2 participants
Member

gfyoung commented Sep 11, 2016 edited

>>> 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 added this to the Next Major Release milestone Sep 12, 2016

gfyoung changed the title from ENH: Accept column indices for na_values in read_csv to BUG: Accept column indices for na_values in read_csv Nov 26, 2016

Member

gfyoung commented Nov 26, 2016

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

@gfyoung gfyoung added a commit to gfyoung/pandas that referenced this issue Nov 26, 2016

@gfyoung gfyoung BUG: Respect column indices for dict-like na_values
Closes gh-14203.
37ed6bf

@gfyoung gfyoung added a commit to gfyoung/pandas that referenced this issue Nov 26, 2016

@gfyoung gfyoung BUG: Respect column indices for dict-like na_values
Closes gh-14203.
8ebba67

@gfyoung gfyoung added a commit to gfyoung/pandas that referenced this issue Nov 26, 2016

@gfyoung gfyoung BUG: Respect column indices for dict-like na_values
Closes gh-14203.
b9b0367

@gfyoung gfyoung added a commit to gfyoung/pandas that referenced this issue Nov 27, 2016

@gfyoung gfyoung + U-GFWY2\Greg BUG: Respect column indices for dict-like na_values
Closes gh-14203.
a2a5b63

@gfyoung gfyoung added a commit to gfyoung/pandas that referenced this issue Nov 27, 2016

@gfyoung gfyoung BUG: Respect column indices for dict-like na_values
Closes gh-14203.
f086bac

@gfyoung gfyoung added a commit to gfyoung/pandas that referenced this issue Dec 1, 2016

@gfyoung gfyoung BUG: Respect column indices for dict-like na_values
Closes gh-14203.
5bd7c10

@gfyoung gfyoung added a commit to gfyoung/pandas that referenced this issue Dec 1, 2016

@gfyoung gfyoung BUG: Respect column indices for dict-like na_values
Closes gh-14203.
0bd7531

@gfyoung gfyoung added a commit to gfyoung/pandas that referenced this issue Dec 15, 2016

@gfyoung gfyoung BUG: Respect column indices for dict-like na_values
Closes gh-14203.
cac422c

@jreback jreback modified the milestone: 0.19.2, Next Major Release Dec 15, 2016

jreback closed this in dd8cba2 Dec 16, 2016

@ischurov ischurov added a commit to ischurov/pandas that referenced this issue Dec 19, 2016

@gfyoung @ischurov gfyoung + ischurov BUG: Patch read_csv NA values behaviour
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 #14203.

Author: gfyoung <gfyoung17@gmail.com>

Closes #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
0f7e6af

@jorisvandenbossche jorisvandenbossche added a commit to jorisvandenbossche/pandas that referenced this issue Dec 24, 2016

@gfyoung @jorisvandenbossche gfyoung + jorisvandenbossche BUG: Patch read_csv NA values behaviour
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 #14203.

Author: gfyoung <gfyoung17@gmail.com>

Closes #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)
c9e5bf4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment