Sure it's simple but can't figure it out.

I've got a code that creates a Dataframe from each tab of a xlsx file, then adds the df to a dictionary of data frames with the sheet name as the key (e.g. df\_dict['sheet 1'] etc. The code uses a loop where the string variable sheet\_name is assigned to the actual sheet name.

I'm now at a point where I want to tell my code to tidy the df up in specific ways according to which df I'm currently referring to, but I can't find how to refer to the Dataframe key. My code uses a string variable 'sheet\_name' in place of the actual key as it loops through sheets.

E.g I want to say 'if df\_dict[sheet\_name] == df\_dict[*'sheet 1'*] then do x'

I think I'm basically getting lost of how to refer to the 'string' or 'key' part of my dataframe in the dictionary in that context.

```
df_dict ={}
counter = 0
list_to_do = ['sheet1','sheet2']

# Defines directory as a path - not just a string
directory = os.fsencode(file_path)

# For each file in the folder
for file in os.listdir(directory):

    # Define the filename
    filename = os.fsdecode(file)

    # If it's a spreadsheet - work on it
    if filename.endswith(".xlsx") or filename.endswith(".xlsx") or filename.endswith(".xlsm"):
        print("Working on " + filename)

        # Add one to the counter to show how many files are worked through and which one you are on
        counter = counter+1
        print('Counter = ' + str(counter))

        # Load the workbook from the given path and filename
        wb = load_workbook(filename = file_path + "/" + filename)

        # Unprotect each sheet and save with new name
        for sheet in wb:
            sheet.protection.disable()

            # Get the name of the current worksheet
            sheet_name = sheet.title
            print('Working on ' + sheet_name)

            if sheet_name in list_to_do:
                # Loads the excel file from the path, specifying the sheet
                df_dict[sheet_name] = pd.read_excel(file_path + "/" + filename,sheet_name)

                # Get rid of unwanted rows at the top according to the specific sheet
                # for all the keys in the dictionary of dataframes with rows to remove at the top

                """if df_dict[sheet_name] == 'sheet1': Do clean up stuff specific to sheet1"""

```