fork download
  1. import pandas as pd
  2.  
  3. # Data from Table S2
  4. data = {
  5. "Domain": [
  6. "Q1. Functional unit defined",
  7. "Q2. System boundaries specified",
  8. "Q3. Stage exclusions justified",
  9. "Q4. Data sources specified",
  10. "Q5. Geographic relevance",
  11. "Q6. Technology data up-to-date",
  12. "Q7. Key assumptions listed",
  13. "Q8. LCIA method identified",
  14. "Q9. Sensitivity/uncertainty analysis",
  15. "Q10. Conclusions supported",
  16. "Q11. Funding/conflicts disclosed"
  17. ],
  18. "Yes": [84.21, 100.00, 0.00, 94.74, 92.11, 81.58, 84.21, 39.47, 57.89, 92.11, 100.00],
  19. "Partly": [15.79, 0.00, 2.63, 5.26, 5.26, 18.42, 10.53, 2.63, 10.53, 5.26, 0.00],
  20. "No": [0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 5.26, 57.89, 26.32, 2.63, 0.00],
  21. "Not Reported": [0.00, 0.00, 97.37, 0.00, 2.63, 0.00, 0.00, 0.00, 5.26, 0.00, 0.00],
  22. }
  23.  
  24. df = pd.DataFrame(data)
  25.  
  26. # Convert percentages to study counts (out of 38)
  27. df["Yes_count"] = (df["Yes"] * 38 / 100).round().astype(int)
  28. df["Partly_count"] = (df["Partly"] * 38 / 100).round().astype(int)
  29. df["No_count"] = (df["No"] * 38 / 100).round().astype(int)
  30. df["NR_count"] = (df["Not Reported"] * 38 / 100).round().astype(int)
  31.  
  32. # Calculate average score per question using scoring rule (Yes=1, Partly=0.5, No/NR=0)
  33. df["Avg_score"] = (
  34. (df["Yes_count"] * 1 + df["Partly_count"] * 0.5) / 38
  35. ).round(2)
  36.  
  37. # Calculate total possible score = 11
  38. # Average study-level quality score (sum of avg_scores across 11 domains)
  39. total_avg_score = df["Avg_score"].sum().round(2)
  40.  
  41. # Classification
  42. if total_avg_score >= 9:
  43. quality = "High quality"
  44. elif total_avg_score >= 6:
  45. quality = "Moderate quality"
  46. else:
  47. quality = "Low quality"
  48.  
  49. import caas_jupyter_tools
  50. caas_jupyter_tools.display_dataframe_to_user("Risk of Bias Scoring Table", df)
  51.  
  52. (total_avg_score, quality)
  53.  
Success #stdin #stdout 0.04s 25432KB
stdin
Standard input is empty
stdout
import pandas as pd

# Data from Table S2
data = {
    "Domain": [
        "Q1. Functional unit defined",
        "Q2. System boundaries specified",
        "Q3. Stage exclusions justified",
        "Q4. Data sources specified",
        "Q5. Geographic relevance",
        "Q6. Technology data up-to-date",
        "Q7. Key assumptions listed",
        "Q8. LCIA method identified",
        "Q9. Sensitivity/uncertainty analysis",
        "Q10. Conclusions supported",
        "Q11. Funding/conflicts disclosed"
    ],
    "Yes": [84.21, 100.00, 0.00, 94.74, 92.11, 81.58, 84.21, 39.47, 57.89, 92.11, 100.00],
    "Partly": [15.79, 0.00, 2.63, 5.26, 5.26, 18.42, 10.53, 2.63, 10.53, 5.26, 0.00],
    "No": [0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 5.26, 57.89, 26.32, 2.63, 0.00],
    "Not Reported": [0.00, 0.00, 97.37, 0.00, 2.63, 0.00, 0.00, 0.00, 5.26, 0.00, 0.00],
}

df = pd.DataFrame(data)

# Convert percentages to study counts (out of 38)
df["Yes_count"] = (df["Yes"] * 38 / 100).round().astype(int)
df["Partly_count"] = (df["Partly"] * 38 / 100).round().astype(int)
df["No_count"] = (df["No"] * 38 / 100).round().astype(int)
df["NR_count"] = (df["Not Reported"] * 38 / 100).round().astype(int)

# Calculate average score per question using scoring rule (Yes=1, Partly=0.5, No/NR=0)
df["Avg_score"] = (
    (df["Yes_count"] * 1 + df["Partly_count"] * 0.5) / 38
).round(2)

# Calculate total possible score = 11
# Average study-level quality score (sum of avg_scores across 11 domains)
total_avg_score = df["Avg_score"].sum().round(2)

# Classification
if total_avg_score >= 9:
    quality = "High quality"
elif total_avg_score >= 6:
    quality = "Moderate quality"
else:
    quality = "Low quality"

import caas_jupyter_tools
caas_jupyter_tools.display_dataframe_to_user("Risk of Bias Scoring Table", df)

(total_avg_score, quality)