adapt this to be not bad 

ef create_schedule(self):
        if len(st.session_state.df) == 0:
            st.info("Fill input table", icon='🚨')
            return
        
        schedules = []
        schedules.append(self.master.create_schedule(datetime.now(),
                                        self.reactor_rate,
                                        self.reactor_attach,
                                        self.line8_attach,
                                        self.line5_attach,
                                        self.lineC_attach))
    
        df = []
        for x in schedules:
            if len(x) > len(df):
                print(len(x))
                df = x
        
        
        #schedule_attempts = []
        #for _ in range(5):
        #    schedule_attempts.append(self.master.create_schedule(datetime.now(),
        #                                 self.reactor_rate,
        #                                 self.reactor_attach,
        #                                 self.line8_attach,
        #                                 self.line5_attach,
        #                                 self.lineC_attach))
        #
        #highest_length = 0
        #for x in schedule_attempts:
        #    st.markdown("Schedule length: "+str(len(x)))
        #    if len(x) > highest_length:
        #        highest_length = len(x)
        #        df = x
            
        st.dataframe(df)
        
        df_dict = {name: group for name, group in df.groupby(level='type')}
        # Access individual DataFrames using the 'type' values
        level_df = df_dict.get('level', pd.DataFrame())
        level_df = level_df.droplevel(level=1)
        grade_df = df_dict.get('grade', pd.DataFrame())
        grade_df = grade_df.droplevel(level=1)
        grade_df = grade_df.fillna(value=0)
        movement_df = df_dict.get('Movement', pd.DataFrame())
        movement_df = movement_df.droplevel(level=1)
        movement_df = movement_df.fillna(value=0)
        
        self.legend_box()
        styled_df = level_df.style.apply(lambda x: movement_df.applymap(self.style_picker), axis=None)
        #move this dataframe to to a session state and make a toggle that swaps the colour between being what is attached and what grade is in it
        pd.set_option('display.precision', 2)
        st.write("Styled DataFrame:")
        st.dataframe(styled_df)
        
        new_data = {'Time': [], 'Reactor - Silo': [], 'Line 8 - Silo': [], 'Line C - Silo': [], 'Line 5 - Silo': []}

        for index, row in movement_df.iterrows():
            columns_with_reactor = [col for col in movement_df.columns if row[col] == 'Reactor']
            new_data['Time'].append(str(index))  # Convert index to string
            new_data['Reactor - Silo'].append(columns_with_reactor)
            columns_with_line8 = [col for col in movement_df.columns if row[col] == 'Line 8']
            new_data['Line 8 - Silo'].append(columns_with_line8)
            columns_with_lineC = [col for col in movement_df.columns if row[col] == 'Line C']
            new_data['Line C - Silo'].append(columns_with_lineC)
            columns_with_line5 = [col for col in movement_df.columns if row[col] == 'Line 5']
            new_data['Line 5 - Silo'].append(columns_with_line5)

        new_df = pd.DataFrame(new_data)
        st.dataframe(new_df)
        
        grade_data = {'Time': [], 'Reactor - Grade': [], 'Line 8 - Grade': [], 'Line C - Grade': [], 'Line 5 - Grade': []}
        for index, row in movement_df.iterrows():
            
            values_with_reactor = [grade_df.loc[index, col] for col in movement_df.columns if row[col] == 'Reactor']
            grade_data['Time'].append(str(index))  # Convert index to string
            grade_data['Reactor - Grade'].append(values_with_reactor)
            values_with_line8 = [grade_df.loc[index, col] for col in movement_df.columns if row[col] == 'Line 8']
            grade_data['Line 8 - Grade'].append(values_with_line8)
            values_with_line5 = [grade_df.loc[index, col] for col in movement_df.columns if row[col] == 'Line 5']
            grade_data['Line 5 - Grade'].append(values_with_line5)
            values_with_lineC = [grade_df.loc[index, col] for col in movement_df.columns if row[col] == 'Line C']
            grade_data['Line C - Grade'].append(values_with_lineC)

        #Style by grade
        grade_df = pd.DataFrame(grade_data)
        st.dataframe(grade_df)

        st.subheader("HDPE REACTOR SCHEDULE")
        
        
        st.subheader("HDPE COMPOUNDING REPORT")