python pandas groupby 之后 根据多列求unique

R语言转成python. 求助
SingleVRef
image.png
R 语言如下

SingleVRef<- unique(SingleVRef[,c("Parameter","Step","max","min")])

写成下面的感觉不对劲

        SingleVRef['max'] = SingleVRef.groupby(['Par','Step'])['Value'].transform(lambda x: x.max())
        SingleVRef['min'] = SingleVRef.groupby(['Par','Step'])['Value'].transform(lambda x: x.min())# min=min(Value))
        SingleVRef = SingleVRef[["Par","Step","max","min"]].groupby(['Par','Step']).apply(lambda x: list(np.unique(x)))
SingleVRef.columns=["Par","Step","refUL","refLL"] 

image.png

阅读 4.2k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏