R语言转成python. 求助
SingleVRef
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"]
Python:
见:pandas.DataFrame.drop_duplicates,unique: Extract Unique Elements。
注意,
nunique()
中的n
表示计数。