DataFrame: Function Not Applying -- "UnboundLocalError: local variable 'month_name' referenced before assignment"
DataFrame: Function Not Applying -- "UnboundLocalError: local variable 'month_name' referenced before assignment"
下面是我的代码:
这是我收到的错误:
UnboundLocalError: local variable 'month_name' referenced before assignment
elif month == 12:
month_name == "Dec"
请注意这个案例(以及最后的默认案例)与之前的 11 个案例有何不同?当 month
为 12 时,您 将 month_name
与 Dec
进行比较,而不是分配它 - 这会失败,因为 month_name
之前没有分配任何值。
下面是我的代码:
这是我收到的错误:
UnboundLocalError: local variable 'month_name' referenced before assignment
elif month == 12:
month_name == "Dec"
请注意这个案例(以及最后的默认案例)与之前的 11 个案例有何不同?当 month
为 12 时,您 将 month_name
与 Dec
进行比较,而不是分配它 - 这会失败,因为 month_name
之前没有分配任何值。