TypeError :("不支持的操作数类型用于&amp ;:' str'和' int'",u'发生在索引48' )数据

时间:2017-08-09 12:33:26

标签: python function pandas dataframe

我有一个数据框,我想创建一个函数,以便从其他2列创建一个列

def day(data=data):
    if data['week_day'] == 'Saturday':
        return 6
    if data['week_day'] == 'Monday':
        return 1
    if data['week_day'] == 'Tuesday':
        return 2
    if data['week_day'] == 'Wednesday':
        return 3
    if data['week_day'] == 'Thursday':
        return 4
    if data['week_day'] == 'Friday':
        return 5
    if data['week_day'] == 'Sunday' & data['Month'] == 7:
        return 7
    if data['week_day'] == 'Sunday' & data['Month'] == 12:
        return 8
    else:
        return 0

    data['week_daye']= data.apply(day,axis=1)

但它得到了这个错误我该怎么解决呢

0 个答案:

没有答案