tyang4 commited on
Commit
e4170ee
·
verified ·
1 Parent(s): 4bd521b

Try to fix vis: column name transform

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +10 -1
src/streamlit_app.py CHANGED
@@ -1058,8 +1058,17 @@ if st.session_state.do_visualize:
1058
  if count_col:
1059
  st.subheader(f"📊 Distribution of {count_col}")
1060
  cnts = df[count_col].astype(str).value_counts()
 
 
 
 
 
 
 
 
 
1061
  try:
1062
- st.bar_chart(cnts)
1063
  except:
1064
  st.info(cnts.head())
1065
 
 
1058
  if count_col:
1059
  st.subheader(f"📊 Distribution of {count_col}")
1060
  cnts = df[count_col].astype(str).value_counts()
1061
+
1062
+ # 转换为 DataFrame
1063
+ cnts = cnts.reset_index()
1064
+ cnts.columns = ['label', 'count']
1065
+
1066
+ # 强制 label 全部转为字符串类型
1067
+ cnts['label'] = cnts['label'].astype(str)
1068
+
1069
+ # 然后用 bar_chart 正常可视化
1070
  try:
1071
+ st.bar_chart(df.set_index("label"))
1072
  except:
1073
  st.info(cnts.head())
1074