✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Default values of dropdown not updated on page load and refresh

I am trying to download a CSV file of the dataframe from graph in my page. By default and on reset, the values for the dropdowns (month, year, status) are 0. However, the CSV renders correctly only on reset. When I load the page or refresh the page, the default dropdown values are not passed to the if condition and it moves to the else condition directly. Can someone help me troubleshoot here?

def download_datafromgraph1(month, year, status):
     if year == 0 and month == 0 and status == 0:
        dff = df2.copy()
        file_name="Count for all ABC in 2020.csv"
        csv_string = dff.to_csv(index = False, encoding = 'utf-8')
        print(csv_string)
        csv_string = "data:text/csv;charset=utf-8," + urllib.parse.quote(csv_string)
        return csv_string , file_name 
     else:
         dff = df.copy()
         dff = df[(df['YEAR'] == year) & (df['MONTH'] == month) & (df['STATUS'] == status)]
         # Generate a unique file name based on the month, year and status
         file_name="Count for all ABCin " + str(month) + "-" + str(year) + " for " + str(status) +" Tickets.csv"
         csv_string = dff.to_csv(index = False, encoding = 'utf-8')
         csv_string = "data:text/csv;charset=utf-8," + urllib.parse.quote(csv_string)
         return csv_string , file_name