pandas每列最大值
时间: 2023-10-12 15:07:01 浏览: 101
要找到pandas中每列的最大值,可以使用DataFrame的max()方法。以下是一个示例代码:
```
import pandas as pd
df = pd.DataFrame({
'id': ['x', 'y', 'z'],
'a': [3, 4, 2],
'b': [0, 5, 7],
'c': [1, 0, 1]
})
max_values = df.max()
```
在这个例子中,`max_values`将会包含每列的最大值。你可以通过索引来访问每列的最大值。例如,`max_values['a']`将会返回列'a'的最大值。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [pandas 获取最大值对应列名](https://blog.csdn.net/weixin_47370009/article/details/125448820)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [pandas将datafram中某列按照条件赋值方法,求每行最大值、均值、和方法](https://blog.csdn.net/leo_weile/article/details/80817883)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文