代码改变世界

pandas 中的 多条件分割, list 排序

2018-02-02 11:35  xplorerthik  阅读(860)  评论(0编辑  收藏  举报

main_comment_num_3m and avg_group_order_cnt_12m = 0.863230
main_comment_score_1m and avg_group_order_cnt_6m = 0.863185
avg_group_order_cnt_1m and avg_main_comment_num_12m = 0.863086
avg_group_coupon_cnt_12m and main_comment_score_6m = 0.863036
avg_main_comment_num_3m and avg_main_buy_user_cnt_12m = 0.863020
groupon_origin_amount_3m and groupon_origin_amount_12m = 0.862878
main_comment_num_3m and group_coupon_user_cnt_12m = 0.862861
avg_main_buy_order_cnt_3m and main_comment_score_12m = 0.862828
avg_main_comment_num_1m and main_buy_order_cnt_3m = 0.862788
group_coupon_cnt_6m and avg_main_comment_score_12m = 0.862236
main_comment_num_1m and main_comment_under_four_score_6m = 0.862236
avg_group_coupon_cnt_3m and main_comment_score_6m = 0.862227
group_order_cnt_1m and avg_main_comment_num_12m = 0.862195
group_coupon_cnt_3m and main_buy_user_cnt_12m = 0.862189
main_order_amount_6m and group_order_amount_12m = 0.862033
online_order_cnt_1m and main_order_cnt_1m = 0.861997

 

data = pd.read_csv('high_corr.txt', header=None, sep = ' and | = ' )  # 注意and 前后含有空格, =前后也有空格

 

setData = [

'group_buy_to_consume_sum_days_1m',
'group_buy_to_consume_sum_days_3m',
'main_comment_under_four_score_12m'

]

setData = sorted(setData, key=lambda d : int(d.split('_')[-1].split('m')[0]))。 按照list中的数字排序