Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
