python - 在 Python/Pandas 中显示不同的值并取最大值
问题描述
我有一个数据集 df,我想只显示最大不同值。
数据
type power
a_b 5
a_c 6
a_c 4
a_c 4
a_b 6
a_b 9
期望的
type power
a_b 9
a_c 6
正在做
df1 = df.unique
df2 = max(df1)
任何建议表示赞赏
解决方案
这是groupby
:
df.groupby('type', as_index=False)['power'].max()
推荐阅读
- javascript - 在 ES6 中选择某些值并按字母顺序排序
- javascript - 使用 ajax 向 Node.js 服务器发送 POST 请求
- php - Apache/PHP 响应时间和执行时间
- symfony - 如何使用 Api 平台过滤器过滤实体子资源
- javascript - 在多个函数中抛出相同 TypeError 的 DRY 方法
- c++ - “未定义的 _imp__ 引用”在 Eclipse 上使用 MinGW
- kubernetes - Kubernetes 删除 pod 作业
- sql - 将 nvarchar 中的属性映射到具有 int 数据类型的另一列
- python - Jupyter notebook 找不到 pyxlsb 模块
- oracle - 使用 JDBC 生成 PySpark Oracle 序列。阅读