xiongdong57 最近的时间轴更新
xiongdong57

xiongdong57

V2EX 第 149526 号会员,加入于 2015-12-01 20:02:08 +08:00
xiongdong57 最近回复了
def category(x):
# column contains N1,N2,N3,N4,sum
level = min(100 - x.loc['sum'], 30) // 10

x = x[["N1", "N2", "N3", "N4"]]
count = (x < 60).sum()
category = level + min(count, 2)

if category < 1:
return "A"
elif category < 2:
return "B"
elif category < 3:
return "C"
else:
return "D"

df['category'] = df.apply(category, axis=1)

规则好像不全,可以全部补充到分类函数里
2016-04-25 18:45:52 +08:00
回复了 xioce 创建的主题 Python 新手, Python LXML 模块安装不了怎么办?
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4298 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 22ms · UTC 10:12 · PVG 18:12 · LAX 02:12 · JFK 05:12
Developed with CodeLauncher
♥ Do have faith in what you're doing.