We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 995b8dd commit 232eea7Copy full SHA for 232eea7
1 file changed
iglu_python/pgs.py
@@ -129,7 +129,10 @@ def pgs_single(subj_data: pd.DataFrame) -> float:
129
130
131
# Calculate PGS for each subject
132
- result = data.groupby("id").apply(lambda x: pgs_single(x), include_groups=True).reset_index()
133
- result.columns = ["id", "PGS"]
134
-
135
- return result
+ results = []
+ for subject_id in data["id"].unique():
+ subject_data = data[data["id"] == subject_id].copy()
+ pgs_value = pgs_single(subject_data)
136
+ results.append({"id": subject_id, "PGS": pgs_value})
137
+
138
+ return pd.DataFrame(results)
0 commit comments