【问题标题】:.idmin() and .idmax() in a Series not working系列中的 .idmin() 和 .idmax() 不起作用
【发布时间】:2020-08-01 13:21:54
【问题描述】:

我正在学习系列中的 python/pandas 属性。我可以让它显示最小值和最大值,但我想显示最小值和最大值索引值,我收到一条错误消息。

google.min()

49.95

google.max()

782.22

google.idmin()

AttributeError Traceback(最近 最后调用) ----> 1 google.idmin(True)

/opt/anaconda3/envs/pandas_playground/lib/python3.8/site-packages/pandas/core/generic.py 在 getattr(self, name) 5272 如果 self._info_axis._can_hold_identifiers_and_holds_name(名称):5273
返回自我[姓名] -> 5274 返回对象。getattribute(self, name) 5275 5276 def setattr(self, name: str, value) -> None:

AttributeError: 'Series' 对象没有属性 'idmin'

【问题讨论】:

  • 你运行的是什么版本的熊猫?你能发布这个print(pd.__version__)的结果吗
  • 1.0.3 我需要更新一些东西吗?

标签: python pandas attributes


【解决方案1】:

经过一番搜索,我发现我只是使用了错误的方法。

idxmin 和 idxmax 工作正常。

google.idxmax()

3011

google.idxmin()

11

【讨论】:

    猜你喜欢
    • 2015-06-16
    • 2018-03-03
    • 2017-05-08
    • 2013-07-29
    • 2017-09-07
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 2016-03-24
    相关资源
    最近更新 更多