Skip to content

Commit 13b4c82

Browse files
Merge pull request #192 from datakind/fix/EdaEndpoint
EDA Endpoint tweaks
2 parents 8317b8f + fa68e08 commit 13b4c82

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/webapp/routers/data.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,9 @@ class TermData(BaseModel):
514514
class DegreeTypeData(BaseModel):
515515
"""Degree type data for donut chart."""
516516

517-
value: int
517+
count: int # Number of students with this degree type
518+
percentage: float # Percentage of total students
518519
name: str
519-
color: str
520520

521521

522522
class StackedBarSeries(BaseModel):
@@ -526,7 +526,6 @@ class StackedBarSeries(BaseModel):
526526
type: str = "bar"
527527
stack: str
528528
data: List[int]
529-
color: str
530529

531530

532531
class EdaDataResponse(BaseModel):
@@ -813,13 +812,9 @@ def get_eda_data(
813812
),
814813
degree_types=[
815814
DegreeTypeData(
816-
value=int(
817-
round(
818-
count / df_cohort["credential_type_sought_year_1"].count() * 100
819-
)
820-
),
815+
count=int(count),
816+
percentage=round(count / df_cohort["study_id"].nunique() * 100, 2),
821817
name=str(degree_type),
822-
color=["#F79222", "#00CFEA", "#25A95A", "#A92532", "#385981"][i % 5],
823818
)
824819
for i, (degree_type, count) in enumerate(
825820
df_cohort["credential_type_sought_year_1"].value_counts().items()
@@ -843,7 +838,6 @@ def get_eda_data(
843838
.reindex(categories, fill_value=0)
844839
.tolist()
845840
),
846-
"color": "#F79222",
847841
},
848842
{
849843
"name": "Part Time",
@@ -858,7 +852,6 @@ def get_eda_data(
858852
.reindex(categories, fill_value=0)
859853
.tolist()
860854
),
861-
"color": "#00CFEA",
862855
},
863856
],
864857
},
@@ -895,7 +888,6 @@ def get_eda_data(
895888
.reindex(pell_categories, fill_value=0)
896889
.tolist()
897890
),
898-
"color": ["#F79222", "#00CFEA", "#25A95A"][i % 3],
899891
}
900892
for i, first_gen_normalized in enumerate(
901893
sorted(
@@ -970,7 +962,6 @@ def get_eda_data(
970962
.reindex(gender_categories, fill_value=0)
971963
.tolist()
972964
),
973-
"color": ["#F79222", "#00CFEA", "#25A95A"][i % 3],
974965
}
975966
for i, age_group in enumerate(
976967
["20 or younger", "20 - 24", "Older than 24"]
@@ -1000,7 +991,6 @@ def get_eda_data(
1000991
.reindex(race_categories, fill_value=0)
1001992
.tolist()
1002993
),
1003-
"color": ["#F79222", "#00CFEA"][i % 2],
1004994
}
1005995
for i, pell_status_normalized in enumerate(
1006996
sorted(

0 commit comments

Comments
 (0)