nithin81 commited on
Commit
9f0f462
·
verified ·
1 Parent(s): 9253b94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -111,13 +111,18 @@ if st.session_state.processed:
111
  selected_table_index = table_options.index(selected_table_option) - 1 # Adjust for "None"
112
  selected_table_df = st.session_state.tables[selected_table_index]
113
 
114
- # Add default columns to the left side of the table with NaN values initially
 
115
  for col in default_columns:
116
- selected_table_df[col] = np.nan
 
117
 
118
  # Move default columns to the left
119
- selected_table_df = selected_table_df[[*default_columns, *selected_table_df.columns[:-len(default_columns)]]]
120
-
 
 
 
121
  if not st.session_state.kv_df.empty:
122
  # Allow the user to select multiple columns using checkboxes
123
  first_row_values = st.session_state.kv_df.iloc[0].values
 
111
  selected_table_index = table_options.index(selected_table_option) - 1 # Adjust for "None"
112
  selected_table_df = st.session_state.tables[selected_table_index]
113
 
114
+
115
+ # Add default columns to the left side of the table with NaN values initially
116
  for col in default_columns:
117
+ if col not in selected_table_df.columns:
118
+ selected_table_df[col] = np.nan
119
 
120
  # Move default columns to the left
121
+ # We include only those columns that exist in the table
122
+ existing_columns = [col for col in default_columns if col in selected_table_df.columns]
123
+ remaining_columns = [col for col in selected_table_df.columns if col not in existing_columns]
124
+ selected_table_df = selected_table_df[[*existing_columns, *remaining_columns]]
125
+
126
  if not st.session_state.kv_df.empty:
127
  # Allow the user to select multiple columns using checkboxes
128
  first_row_values = st.session_state.kv_df.iloc[0].values