build_features.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:KaggleExeter 作者: detomo 项目源码 文件源码
def rename_brands(phone_models):
    """ recast all phone brands and model as string integers brand_i and model_j """
    brands_table = {}
    i = 0
    for brand in pd.unique(phone_models['phone_brand']):
        brands_table[brand] = 'brand_%s' %i
        i += 1

    models_table = {}
    i = 0
    for model in pd.unique(phone_models['device_model']):
        models_table[model] = 'model_%s' %i
        i += 1

    converted = []
    for item in zip(phone_models['phone_brand'],phone_models['device_model']):
        converted.append((brands_table[item[0]],models_table[item[1]]))
    phone_models['phone_brand'] = [x[0] for x in converted]
    phone_models['device_model'] = [x[1] for x in converted]
    return phone_models
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号