财力评级统计优化
This commit is contained in:
@@ -26,7 +26,7 @@ def stat(community_summary_df):
|
||||
grouped = community_summary_df.groupby(["city"])
|
||||
|
||||
results = []
|
||||
for item, group in grouped:
|
||||
for city, group in grouped:
|
||||
# 计算财力评级指标
|
||||
rating_counts = group["consumption_rating"].value_counts(normalize=True)
|
||||
rating_1 = rating_counts.get(1, 0)
|
||||
@@ -48,7 +48,7 @@ def stat(community_summary_df):
|
||||
confidence_counts = group["credit"].value_counts(normalize=True)
|
||||
|
||||
results.append({
|
||||
"城市": item[0],
|
||||
"城市": city,
|
||||
"财力评级1级占比": round(rating_1 * 100, 1),
|
||||
"财力评级1级分数范围": f"{rating_1_scores.min():.0f}-{rating_1_scores.max():.0f}" if not rating_1_scores.empty else "-",
|
||||
"财力评级2级占比": round(rating_2 * 100, 1),
|
||||
|
||||
Reference in New Issue
Block a user