I have a data frame as shown below
X Y Z cluster
245 256882.0 4110945 426.50 20
246 256882.7 4110945 426.42 57
247 256883.9 4110945 429.30 114
248 256884.6 4110945 428.93 114
249 256885.4 4110945 429.50 98
250 256886.1 4110945 429.67 33
The dataframe is having 4 columns with x, y, z and clustered output. xy are the coordinates and z is the corresponding height. I clustered the entire data points using kmeans into 176 clusters. Now I want to take max z value from each cluster. for example, from cluster value 1, I need to identify the max z value and need to take the corresponding x and y values too. How can I do that?