Answered step by step
Verified Expert Solution
Question
1 Approved Answer
def what _ year _ debug ( fraction = 0 . 5 , source = 'Both' ) : # Calculate cumulative sums of emissions by
def whatyeardebugfraction source'Both':
# Calculate cumulative sums of emissions by year for each source
dfemissionsCumulativeFossil' dfemissionsCoal 'Oil', 'Gas', 'Cement', 'Flaring', 'Other'sumaxiscumsum
dfemissionsCumulativeLand' dfemissionsLandcumsum
dfemissionsCumulativeBoth' dfemissionsCumulativeFossil' dfemissionsCumulativeLand'
# Get the total cumulative emissions for the specified source
totalemissions dfemissionsfCumulativesourceiloc
# Find the year where the cumulative emissions exceed the fraction of interest
targetemissions totalemissions fraction
yearrow dfemissionsdfemissionsfCumulativesource targetemissionsiloc
# Return the year as an integer
return intyearrowYear
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started