I have a data frame that looks something like this.
import pandas as pd
data = [[5, 7, 10], [7, 20, 4,], [8, 1, 6,]]
cities = ['Boston', 'Phoenix', 'New York']
df = pd.DataFrame(data, columns=cities, index=cities)
Output:
Boston Phoenix New York
Boston 5 7 10
Phoenix 7 20 4
New York 8 1 6
And I want to be able to find the city pair with the greatest value. In this case I would want to return Phoenix,Phoenix.
I have tried:
cityMax = df.values.max()
cityPairs = df.idxmax()
The first one only gives me the largest value (20) and the second gives me each cities max pair not just the overall max. Is there a way to return the index and column header for a specified value in a dataframe?