I'm working on a dashboard with information about tennis professional players.
I got this for loop and I'm getting the desired output:
for ind in df.index:
if df['Winner'][ind] == 'Nadal R.' and df['Loser'][ind] == 'Djokovic N.':
print(df.iloc[ind]['Location'], ': ', df.iloc[ind]['Wsets'], '-', df.iloc[ind]['Lsets'])
OUTPUT:
Madrid : 2.0 - 0.0
Rome : 2.0 - 0.0
Rome : 2.0 - 1.0
Paris : 3.0 - 0.0
Rome : 2.0 - 1.0
But when I try to pass it into my dash app I have to create a function for the callback to work.
So I defined the following function (notice that input_value1
and input_value_2
are the same that in the code above by default):
def update_output_div(input_value1, input_value2):
for ind in df.index:
if df['Winner'][ind] == input_value1 and df['Loser'][ind] == input_value2:
return df.iloc[ind]['Location'], ': ', df.iloc[ind]['Wsets'], '-', df.iloc[ind ['Lsets']
OUTPUT:
Madrid : 2.0 - 0.0
What I want to do is to display on my dash app the same output as the code on top.