【发布时间】:2017-06-30 17:03:23
【问题描述】:
错误:
AttributeError: 'DataFrame' object has no attribute 'map'
代码: 我创建了一个函数来根据不同列中的值对数据框中的一些时间事件(行)进行分类。
def usage(x):
if x['Dest']==x['Origin']: return 'round'
elif x['Origin']==x['next_dest']:
if x['Dest']==x['next_origin']: return 'perfectsym'
else: return 'nonperfectsym'
else: 'None'
有了这个,我希望能够使用地图功能来分类新列中的条目,如下所示:
All_data['usagetype'] = All_Data.map(usage)
但这不起作用。
感谢您的帮助。
【问题讨论】:
标签: python-3.x pandas anaconda