如何在python数据框中查找列的最大值 [英] How to find maximum value of a column in python dataframe

查看:1225
本文介绍了如何在python数据框中查找列的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 pyspark 中有一个数据框。在此数据框中,我有一个名为 id 的列。

I have a data frame in pyspark. In this data frame I have column called id that is unique.

现在我想找到<$ c数据框中列 id 的$ c>最大值。

Now I want to find the maximum value of the column id in the data frame.

I尝试如下

df['id'].max()

但是出现以下错误

TypeError: 'Column' object is not callable

请让我知道如何找到最大值数据框中列的值

Please let me know how to find the maximum value of a column in data frame


在@Dadep的答案中,链接给出了正确的答案

In the answer by @Dadep the link gives the correct answer


推荐答案

如果您使用的是熊猫 .max()会起作用:

if you are using pandas .max() will work :

>>> df2=pd.DataFrame({'A':[1,5,0], 'B':[3, 5, 6]})
>>> df2['A'].max()
5

否则为 spark 数据帧:

Best way to get the max value in a Spark dataframe column

这篇关于如何在python数据框中查找列的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆