由于 dataframe.std() 已弃用,我们现在应该使用 groupby:https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.GroupBy.std.html
但是,为了找到这个的简单标准差
dataframe['number'].std(),
groupby 函数对我来说似乎是一个不必要的长命令。 “dataframe”有一列“数字”,范围从 1 到 100。
使用 groupby 时上面的行会是什么样子?
最佳答案
我认为对docs存在误解。 .
pandas 所弃用的具体是 level
参数有利于其 groupby counterpart (您分享的链接)。没有任何地方写着pandas.Series.std
整体已弃用:
level: int or level name, default None If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a scalar.
block 引用>Deprecated since version 1.3.0: The level keyword is deprecated. Use groupby instead.
和:
numeric_only: bool, default None Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.
block 引用>Deprecated since version 1.5.0: Specifying numeric_only=None is deprecated. The default value will be False in a future version of pandas.
鉴于您建议的代码行,我认为没有理由更改它。继续使用:
df['col'].std()
关于python - 数据框的标准差?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74215072/