import pandas as pd ts = pd.read_csv("/home/claude/carbon_project/final/nigeria_carbon_timeseries.csv") comp = pd.read_csv("/home/claude/carbon_project/final/nigeria_carbon_comparison_2022.csv") rows = [] # ── Row 1: Total vs per-capita divergence, 2000-2024 ── co2_2000 = ts[ts['year']==2000]['co2'].values[0] co2_2024 = ts[ts['year']==2024]['co2'].values[0] pc_2000 = ts[ts['year']==2000]['co2_per_capita'].values[0] pc_2024 = ts[ts['year']==2024]['co2_per_capita'].values[0] total_change = (co2_2024/co2_2000 - 1) * 100 pc_change = (pc_2024/pc_2000 - 1) * 100 rows.append({ "prompt": f"Nigeria's CO2 emissions, from Our World in Data: 2000, total {co2_2000} million tonnes, per-capita {pc_2000} tonnes. 2024, total {co2_2024} million tonnes, per-capita {pc_2024} tonnes. Calculate the percentage change in each and interpret the divergence.", "completion": f"Total emissions rose {total_change:.1f}% ({co2_2000} to {co2_2024} million tonnes) while per-capita emissions fell {abs(pc_change):.1f}% ({pc_2000} to {pc_2024} tonnes) over the same 24-year period. This divergence means population growth outpaced emissions growth, Nigeria's population roughly doubled over this period while its total emissions grew by less than half that rate. A rising total with a falling per-capita figure is not necessarily a sign of improving carbon efficiency; it primarily reflects demographic growth diluting a real, absolute emissions increase, and both figures matter for different purposes, total for global climate accounting, per-capita for equity comparisons.", "source": "Our World in Data, owid/co2-data (GitHub), downloaded directly" }) # ── Row 2: Nigeria vs South Africa per-capita gap ── nigeria_pc = comp[comp['country']=='Nigeria']['co2_per_capita'].values[0] sa_pc = comp[comp['country']=='South Africa']['co2_per_capita'].values[0] sa_coal = comp[comp['country']=='South Africa']['coal_co2'].values[0] sa_total = comp[comp['country']=='South Africa']['co2'].values[0] sa_coal_share = sa_coal/sa_total*100 ratio = sa_pc/nigeria_pc rows.append({ "prompt": f"2022 comparison, from Our World in Data: Nigeria per-capita CO2 {nigeria_pc} tonnes, South Africa per-capita CO2 {sa_pc} tonnes (of which {sa_coal} million tonnes, or {sa_coal_share:.1f}%, comes from coal). Calculate the ratio and interpret the driver.", "completion": f"South Africa's per-capita emissions are {ratio:.1f} times higher than Nigeria's ({sa_pc} vs {nigeria_pc} tonnes), and coal alone accounts for {sa_coal_share:.1f}% of South Africa's total emissions, the dominant driver of the gap. This is not primarily a population or development-level difference, both are major African economies, it reflects a fundamentally different energy mix: South Africa's electricity grid remains heavily coal-dependent, while Nigeria's emissions are split more evenly between oil and gas. This means South Africa's path to reducing its per-capita emissions runs specifically through decarbonizing electricity generation, a different policy lever than what would primarily affect Nigeria's emissions profile.", "source": "Our World in Data, owid/co2-data (GitHub), downloaded directly" }) # ── Row 3: Carbon intensity of GDP, Nigeria as least carbon-intensive ── nigeria_intensity = comp[comp['country']=='Nigeria']['co2_per_gdp'].values[0] sa_intensity = comp[comp['country']=='South Africa']['co2_per_gdp'].values[0] world_intensity = comp[comp['country']=='World']['co2_per_gdp'].values[0] rows.append({ "prompt": f"Carbon intensity of GDP, 2022, from Our World in Data (kg CO2 per dollar of GDP): Nigeria {nigeria_intensity}, South Africa {sa_intensity}, World average {world_intensity}. Interpret Nigeria's position given its status as a major oil-producing economy.", "completion": f"Nigeria's carbon intensity ({nigeria_intensity} kg CO2/$) is lower than both South Africa's ({sa_intensity}, {sa_intensity/nigeria_intensity:.1f}x higher) and the World average ({world_intensity}, {world_intensity/nigeria_intensity:.1f}x higher), despite Nigeria's economy being closely associated with oil production. This is a genuinely counterintuitive finding: being a major oil producer does not automatically mean a carbon-intensive domestic economy, since Nigeria's oil is predominantly extracted for export rather than domestic industrial consumption, meaning the emissions embodied in that oil are largely counted against the economies that burn it, not Nigeria's own GDP-linked emissions. This distinction between production-based and consumption-based carbon accounting is essential context, Nigeria's low carbon intensity reflects its economic structure, not necessarily efficient or clean domestic energy use.", "source": "Our World in Data, owid/co2-data (GitHub), downloaded directly" }) # ── Row 4: Trade CO2, Nigeria as net importer vs South Africa net exporter ── nigeria_trade = comp[comp['country']=='Nigeria']['trade_co2'].values[0] sa_trade = comp[comp['country']=='South Africa']['trade_co2'].values[0] rows.append({ "prompt": f"Trade-embodied CO2, 2022, from Our World in Data (positive means net importer of embodied carbon, negative means net exporter): Nigeria {nigeria_trade} million tonnes, South Africa {sa_trade} million tonnes. Interpret what this means for each country's consumption-based emissions.", "completion": f"Nigeria is a net importer of embodied carbon ({nigeria_trade} million tonnes positive), meaning its consumption-based emissions (what Nigerians actually use, including imported goods) exceed its production-based emissions (what's physically emitted within Nigeria's borders). South Africa shows the opposite pattern, a large net exporter of embodied carbon ({sa_trade} million tonnes negative), consistent with its heavy industrial and mining export sector. This means any climate policy comparison based purely on production emissions understates Nigeria's true consumption footprint and overstates South Africa's, since a meaningful share of South Africa's production emissions are embedded in goods consumed elsewhere, not domestically.", "source": "Our World in Data, owid/co2-data (GitHub), downloaded directly" }) # ── Row 5: Oil and gas growth as share of Nigeria's emissions ── oil_2000 = ts[ts['year']==2000]['oil_co2'].values[0] oil_2024 = ts[ts['year']==2024]['oil_co2'].values[0] gas_2000 = ts[ts['year']==2000]['gas_co2'].values[0] gas_2024 = ts[ts['year']==2024]['gas_co2'].values[0] oil_growth = (oil_2024/oil_2000 - 1) * 100 gas_growth = (gas_2024/gas_2000 - 1) * 100 rows.append({ "prompt": f"Nigeria's emissions by fuel source, from Our World in Data: 2000, oil {oil_2000} million tonnes, gas {gas_2000} million tonnes. 2024, oil {oil_2024} million tonnes, gas {gas_2024} million tonnes. Calculate the growth rate of each and interpret which fuel is driving Nigeria's emissions trajectory.", "completion": f"Oil-related emissions grew {oil_growth:.1f}% over the period ({oil_2000} to {oil_2024} million tonnes), while gas-related emissions grew {gas_growth:.1f}% ({gas_2000} to {gas_2024} million tonnes), meaning gas emissions grew roughly {gas_growth/oil_growth:.1f} times faster than oil emissions in relative terms, even though oil remains the larger absolute source. This is consistent with Nigeria's well-documented shift toward gas-fired power generation over this period, gas's rapid relative growth reflects genuine structural change in the energy mix, not just overall economic growth, since if all fuels grew proportionally with the economy, oil and gas growth rates would be closer together rather than diverging this much.", "source": "Our World in Data, owid/co2-data (GitHub), downloaded directly" }) df = pd.DataFrame(rows) df.to_csv("/home/claude/carbon_project/final/nigeria_carbon_interpreter_dataset.csv", index=False) print(f"Built {len(df)} rows") print(f"Avg prompt length: {df['prompt'].str.split().str.len().mean():.1f} words") print(f"Avg completion length: {df['completion'].str.split().str.len().mean():.1f} words")