python 报错:AttributeError: ("'list' object has no attribute 'map'", 'occurred at index 0')
def function(x, y, z):
if x <= 100 and y == 'AB':
return (list(z).map(concept_hierarchy(0))) * disc
elif x <= 200 and y == 'AC':
return (list(z).map(concept_hierarchy(1))) * disc
else:
return None
data['abc'] = data.apply(lambda x: function(x['a'], x['b'], x['c']), axis=1)
代码主要是对数据表里面,C列的值(特征较多,字符型)进行关系映射(转为数值)。