题解 | #某店铺用户消费特征评分#

某店铺用户消费特征评分

https://www.nowcoder.com/practice/200c824e9ed4428491c27d65ec56067d

import pandas as pd
sales = pd.read_csv('sales.csv')

sales['R_Quartile'] = pd.qcut(sales['recency'],[0, 0.25, 0.5, 0.75, 1],['4','3','2','1']).astype("int")
sales['F_Quartile'] = pd.qcut(sales['frequency'],[0, 0.25, 0.5, 0.75, 1],['1','2','3','4']).astype("int")
sales['M_Quartile'] = pd.qcut(sales['monetary'],[0, 0.25, 0.5, 0.75, 1],['1','2','3','4']).astype("int")
print(sales.head())

注意一定要将文字改成整数类型int

全部评论

相关推荐

09-28 18:14
门头沟学院 Java
小肥罗:离谱,那我的简历可以这么写:颜值高大长腿,一张臭嘴不要脸,四只眼瓜子脸,入职不用买保险。
我的秋招日记
点赞 评论 收藏
分享
点赞 评论 收藏
分享
码农索隆:谁问你了 举报了 删了,求你了 我要哭了 我一点也不眼红 我要跳楼
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务