Reputation: 1521
In pyspark, if I use the following code to calculate max value, I will get result like "Row(max(age)=5)]". But is there a way that I can save the output value 5 into a parameter such as max_age?
print(x.agg({"age": "max"}).collect())
Upvotes: 1
Views: 338
Reputation: 2545
Yes, you can. You simply need to extract the value.
max_age = x.agg({"age": "max"}).collect()[0]['max(age)']
Upvotes: 1