Skip to content

DataFrame.replace: TypeError: Cannot compare types 'ndarray(dtype=int64)' and 'unicode' #16784

Closed
@eromoe

Description

@eromoe

Code Sample, a copy-pastable example if possible

path1 = '/some.xls'
df1 = pd.read_excel(path1)
columns_values_map={
    'positive': {
        '正面':1,
        '中立': 1,
        '负面':0
    }
}

df1.replace(columns_values_map)

Problem description

got error: TypeError: Cannot compare types 'ndarray(dtype=int64)' and 'unicode'

Actually df1['positive'] only has value in (0, 1) , but I think it should not throw exception here.

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