code

这里写自定义目录标题

欢迎使用Markdown编辑器

你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。

代码片

博客设置页面,选择一款你喜欢的代码片高亮样式,下面展示同样高亮的 代码片.

// An highlighted block
for dataset, df_tmp in DF_UNION_MAPPING.items():
    print("saving dataset {0}".format(dataset))
    
    unique_keys = None
    variable_types = None
    
    dataset_token = dataset[2:]
    if dataset.startswith('F_'):
        unique_keys = DATASET_PARSER_TOOLS.DATASET_UNIQUE_KEYS_MAPPING[dataset_token]
        variable_types = DatasetParserTools.adaptive_extend_ft_types(DATASET_PARSER_TOOLS.DATASET_FT_TYPES_MAPPING[dataset_token], list(df_tmp.columns))
    else:
        unique_keys = [DICT_TABLE_UNIQUE_ID_MAPPING[dataset_token]]
        variable_types = ADDITIONAL_FT_TYPES_MAPPING[dataset_token]
    
    print("### {0}'s shape is ###\n{1}".format(dataset, df_tmp.shape))
    for key in unique_keys:
        print("{0} <- count(distinct({1}))".format(df_tmp[key].nunique(), key))

    unique_index = None
    if len(unique_keys) > 1:
        composite_index_name, composite_index = DatasetParserTools.build_composite_index(df_tmp, unique_keys)
        print("{0} <- count(distinct({1}))".format(composite_index.nunique(), composite_index_name))
        df_tmp[composite_index_name] = composite_index
        
        unique_index = composite_index_name
    else:
        unique_index = unique_keys[0]

#     print("unique index is {0}".format(unique_index))        
        
    df_tmp.drop_duplicates(subset = unique_index, keep = 'last', inplace = True)
#     df_tmp.dtypes
    
    # shuffle
    df_tmp = df_tmp.sample(frac=1, random_state=139).reset_index(drop=True)
    

    es = es.entity_from_dataframe(entity_id = dataset, 
                            dataframe = df_tmp,
                            variable_types = variable_types,
                            index = unique_index
                        )
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值