Skip to content

fix: add dataframe sorting to fix data rank assignment #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion soil_id/us_soil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1986,10 +1986,13 @@ def rank_soils(

# Concatenate the sorted and ranked groups
D_final = pd.concat(soilIDList_data).reset_index(drop=True)

# Merge with the Rank_Filter data
D_final = pd.merge(D_final, Rank_Filter, on="compname", how="left")

# Sort dataframe to correctly assign Rank_Data
D_final = D_final.sort_values(by=["soilID_rank_data", "Score_Data"], ascending=[False, False])

# Assigning rank based on the soilID rank and rank status
rank_id = 1
Rank_Data = []
Expand All @@ -2003,6 +2006,7 @@ def rank_soils(
rank_id += 1

D_final["Rank_Data"] = Rank_Data

"""
Code options for production API/testing output
# ----------------------------------------------------------------
Expand Down