Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -49,33 +49,10 @@ def load_data(file):
|
|
49 |
else:
|
50 |
st.error("μ§μλμ§ μλ νμΌ νμμ
λλ€. CSV, XLS, λλ XLSX νμΌμ μ
λ‘λν΄μ£ΌμΈμ.")
|
51 |
return None
|
52 |
-
|
53 |
-
# λΉ
|
54 |
if data.columns.isnull().any():
|
55 |
-
|
56 |
-
for i, col in enumerate(data.columns):
|
57 |
-
if pd.isnull(col):
|
58 |
-
new_columns.append(f'Column_{i+1}')
|
59 |
-
else:
|
60 |
-
new_columns.append(col)
|
61 |
-
data.columns = new_columns
|
62 |
-
|
63 |
-
st.warning("μΌλΆ μ΄ μ΄λ¦μ΄ λΉμ΄ μμ΄μ μλμΌλ‘ μ΄λ¦μ λΆμ¬νμ΅λλ€.")
|
64 |
-
|
65 |
-
# μ¬μ©μμκ² μ΄ μ΄λ¦ μμ κΈ°ν μ 곡
|
66 |
-
st.write("νμ¬ μ΄ μ΄λ¦:")
|
67 |
-
st.write(data.columns.tolist())
|
68 |
-
|
69 |
-
if st.checkbox("μ΄ μ΄λ¦μ μμ νμκ² μ΅λκΉ?"):
|
70 |
-
new_column_names = st.text_input("μλ‘μ΄ μ΄ μ΄λ¦μ μΌνλ‘ κ΅¬λΆνμ¬ μ
λ ₯νμΈμ:",
|
71 |
-
value=",".join(data.columns))
|
72 |
-
new_column_names = [name.strip() for name in new_column_names.split(",")]
|
73 |
-
|
74 |
-
if len(new_column_names) == len(data.columns):
|
75 |
-
data.columns = new_column_names
|
76 |
-
st.success("μ΄ μ΄λ¦μ΄ μ±κ³΅μ μΌλ‘ μ
λ°μ΄νΈλμμ΅λλ€.")
|
77 |
-
else:
|
78 |
-
st.error("μ
λ ₯ν μ΄ μ΄λ¦μ κ°μκ° νμ¬ μ΄ κ°μμ μΌμΉνμ§ μμ΅λλ€.")
|
79 |
|
80 |
return data
|
81 |
|
@@ -228,9 +205,18 @@ def main():
|
|
228 |
|
229 |
if st.session_state.data is not None:
|
230 |
st.subheader("λ°μ΄ν° 미리보기 λ° μμ ")
|
231 |
-
st.write("λ°μ΄ν°λ₯Ό νμΈνκ³ νμν κ²½μ°
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
edited_data = st.data_editor(st.session_state.data, num_rows="dynamic", key="data_editor")
|
233 |
|
|
|
|
|
|
|
234 |
if st.button("λ°μ΄ν° λΆμ μμ", key="start_analysis") or st.session_state.analysis_performed:
|
235 |
if not st.session_state.analysis_performed:
|
236 |
st.session_state.processed_data = preprocess_data(edited_data)
|
|
|
49 |
else:
|
50 |
st.error("μ§μλμ§ μλ νμΌ νμμ
λλ€. CSV, XLS, λλ XLSX νμΌμ μ
λ‘λν΄μ£ΌμΈμ.")
|
51 |
return None
|
52 |
+
|
53 |
+
# λΉ μ΄ μ΄λ¦μ κΈ°λ³Έκ° λΆμ¬
|
54 |
if data.columns.isnull().any():
|
55 |
+
data.columns = [f'Column_{i+1}' if pd.isnull(col) else col for i, col in enumerate(data.columns)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
return data
|
58 |
|
|
|
205 |
|
206 |
if st.session_state.data is not None:
|
207 |
st.subheader("λ°μ΄ν° 미리보기 λ° μμ ")
|
208 |
+
st.write("λ°μ΄ν°λ₯Ό νμΈνκ³ νμν κ²½μ° μμ νμΈμ. μ΄ μ΄λ¦λ μ§μ μμ ν μ μμ΅λλ€:")
|
209 |
+
|
210 |
+
# μ΄ μ΄λ¦ νΈμ§μ μν λ°μ΄ν° νλ μ μμ±
|
211 |
+
column_df = pd.DataFrame({'column_name': st.session_state.data.columns})
|
212 |
+
edited_columns = st.data_editor(column_df, num_rows="dynamic", key="column_editor")
|
213 |
+
|
214 |
+
# λ°μ΄ν° νΈμ§
|
215 |
edited_data = st.data_editor(st.session_state.data, num_rows="dynamic", key="data_editor")
|
216 |
|
217 |
+
# μ΄ μ΄λ¦ μ
λ°μ΄νΈ
|
218 |
+
edited_data.columns = edited_columns['column_name']
|
219 |
+
|
220 |
if st.button("λ°μ΄ν° λΆμ μμ", key="start_analysis") or st.session_state.analysis_performed:
|
221 |
if not st.session_state.analysis_performed:
|
222 |
st.session_state.processed_data = preprocess_data(edited_data)
|