python 'SeriesGroupBy' object has no attribute quantile(0.1)

R语言转成python. 求助

R 语言如下

SingleM <- data.frame(SingleM %>% group_by(Parameter,filename)%>% 

mutate(P10=quantile (Value, probs=0.1), P90=quantile (Value, probs=0.9),

max=max(Value), min=min(Value)))

Python 写成下面的不对

SingleM = SingleM.groupby(['Par','Filename']).agg( P10=('Value','quantile(0.1)'), P90= ('Value', 'quantile(0.9)'), max = ('Value','max'), min = ('Value', 'min'))

python 报错如下:
AttributeError: 'SeriesGroupBy' object has no attribute 'quantile(.1)'

SingleM = SingleM.groupby(['Par','Filename']).apply(lambda x: pd.DataFrame([[x.Value.quantile(0.1),x.Value.quantile(0.9),x.Value.max(),x.Value.min()]],columns=['P10','P90','max','min'])).reset_index()#P10=(quantile(Value,0.1)), P90= (np.quantile(Value,0.9)),

第二种写法应该正确 但是如何去掉那个level 2 的列呢,试了reset_index() 好像也有问题
python  'SeriesGroupBy' object has no attribute quantile(0.1)

df quantile API 如下:
pandas.DataFrame.quantile
DataFrame.quantile(q=0.5, axis=0, numeric_only=True, interpolation='linear')

以上是 python &#x27;SeriesGroupBy&#x27; object has no attribute quantile(0.1) 的全部内容, 来源链接: utcz.com/p/938165.html

回到顶部