Skip to content

ERR: read_csv with dtype specified on empty data #12048

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
Sereger13 opened this issue Jan 15, 2016 · 3 comments
Closed

ERR: read_csv with dtype specified on empty data #12048

Sereger13 opened this issue Jan 15, 2016 · 3 comments
Labels
Error Reporting Incorrect or improved errors from pandas IO CSV read_csv, to_csv
Milestone

Comments

@Sereger13
Copy link
Contributor

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

@jreback
Copy link
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 jreback added Error Reporting Incorrect or improved errors from pandas IO CSV read_csv, to_csv labels Jan 15, 2016
@jreback jreback added this to the Next Major Release milestone Jan 15, 2016
@jreback jreback changed the title read_csv fails when skiprows and dtype are specified ERR: read_csv with dtype specified on empty data Jan 15, 2016
@Sereger13
Copy link
Contributor Author

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'.

@jreback
Copy link
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 added a commit to Sereger13/pandas that referenced this issue Jan 21, 2016
@jreback jreback modified the milestones: 0.18.0, Next Major Release Jan 21, 2016
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 a pull request may close this issue.

2 participants