fix: prevent DataFrame mutation in prepare_data() causing indication charts to fail
prepare_data() mapped Provider Code → Name in-place. When called for directory charts first, then indication charts, the second call re-mapped already-mapped values to NaN, silently dropping all data. Added df.copy() to prevent mutation. Also fixes directory charts only generating data for the first date filter. Results: 3,633 pathway nodes now generated (1,101 directory + 2,532 indication) across all 12 datasets (6 date filters × 2 chart types).
This commit is contained in:
@@ -53,6 +53,10 @@ def prepare_data(
|
||||
if paths is None:
|
||||
paths = default_paths
|
||||
|
||||
# Work on a copy to avoid mutating the caller's DataFrame
|
||||
# (Provider Code mapping is destructive — second call would map names to NaN)
|
||||
df = df.copy()
|
||||
|
||||
df["UPIDTreatment"] = df["UPID"] + df["Drug Name"]
|
||||
|
||||
org_codes = pd.read_csv(paths.org_codes_csv, index_col=1)
|
||||
|
||||
Reference in New Issue
Block a user