ERR: read_csv with dtype specified on empty data #12048

Closed
Sereger13 opened this Issue Jan 15, 2016 · 3 comments

Comments

Projects
None yet
2 participants

File has this content:

A,A
3,3

When I do pd.read_csv(filepath) - all looks fine, however if I specify skiprows and dtype parameters it fails with the following error:

pd.read_csv(filepath, skiprows=1, dtype=str)

AttributeError: type object 'str' has no attribute 'items'


INSTALLED VERSIONS

commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.18-238.9.1.el5
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US

pandas: 0.17.1

Contributor

jreback commented Jan 15, 2016

This is equivalent to this. So this doesn't have any data, so the dtype converter should handle this properly.

In [13]: read_csv(StringIO(data),header=0,skiprows=1)
Out[13]: 
Empty DataFrame
Columns: [3, 3.1]
Index: []

In [14]: data
Out[14]: 'A,A\n3,3'

So an even simpler repro is this.

In [16]: read_csv(StringIO('A,B'),dtype=str)
AttributeError: type object 'str' has no attribute 'items'

care to do a pull-request to fix?

jreback added this to the Next Major Release milestone Jan 15, 2016

jreback changed the title from read_csv fails when skiprows and dtype are specified to ERR: read_csv with dtype specified on empty data Jan 15, 2016

Prepared the fix locally but getting this error when trying to send pull-request:
'It seems you do not have permission to push your changes to this repository'.

Contributor

jreback commented Jan 19, 2016

see contributing docs here

you need to fork, then push to your branch and open a PR.

you are trying to push to master

@Sereger13 Sereger13 pushed a commit to Sereger13/pandas that referenced this issue Jan 21, 2016

Sereger13 Fix for #12048 a8744ce

@jreback jreback modified the milestone: 0.18.0, Next Major Release Jan 21, 2016

jreback closed this in ab3291d Jan 24, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment