涉及到的方法
apply
示例代码
def function(x, types):if types == "title":return "%s-%s栋%s%s号" % (x["区域"], x["ridgepole_num"],x["房屋分类"], x["house_num"])else:raise Exception500000("不在枚举范围内")res_df = pd.DataFrame(queryset)# 示例一res_df["区域"] = res_df.region.apply(lambda x: dict(region_choices)[x])# 示例二res_df["标题"] = res_df.apply(lambda x: function(x, "title"), axis=1)
