Skip to content

Unicode not acceptable input for usecols kwarg in read_csv() #13219

Closed
@PeterKucirek

Description

@PeterKucirek

I caught this bug while updating from version 0.18.0 to 0.18.1. The kwarg usecols no longer accepts unicode column labels.

Example below:

from io import StringIO
import pandas as pd

s = u'''AAA,BBB,CCC,DDD
0.056674973,8,True,a
2.613230982,2,False,b
3.568935038,7,False,a
'''
buff = StringIO(s)
print pd.read_csv(buff, usecols=[u'AAA', u'BBB'])

>> ValueError: The elements of 'usecols' must either be all strings or all integers

I note that 0.18.1 introduced the requirement that usecols be all string or all ints. This makes sense but it looks like the implementation also throws away unicode strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions