This notebook recomputes the page’s headline numbers from the raw Our World in Data file. It runs from scratch on every build.
import pandas as pd, hashlib
raw = open('energy.csv','rb').read(); print('sha256', hashlib.sha256(raw).hexdigest()[:16])
df = pd.read_csv('energy.csv')
w = df[(df.country=='World') & df.solar_electricity.notna() & df.coal_electricity.notna()].sort_values('year').iloc[-1]
F = ['coal','gas','oil','nuclear','hydro','wind','solar','biofuel','other_renewable_exc_biofuel']
tot = sum(w[f+'_electricity'] for f in F); print(int(w.year), round(tot), 'TWh')
sha256 266f2e2baad79753
2025 31772 TWh
shares = pd.Series({f: w[f+'_electricity']/tot*100 for f in F}).sort_values(ascending=False).round(1)
shares.to_frame('share of world electricity, %')
| coal |
33.0 |
| gas |
21.8 |
| hydro |
14.0 |
| nuclear |
8.8 |
| solar |
8.7 |
| wind |
8.5 |
| oil |
2.6 |
| biofuel |
2.2 |
| other_renewable_exc_biofuel |
0.3 |
import matplotlib.pyplot as plt
wd = df[(df.country=='World') & (df.year>=1985)].set_index('year')
ax = wd[['coal_electricity','gas_electricity','solar_electricity','wind_electricity']].plot(figsize=(9,4), lw=2)
ax.set_ylabel('TWh'); ax.set_title('World electricity by source'); plt.tight_layout()
Speed of light from Maxwell
\(c = 1/\sqrt{\mu_0\varepsilon_0}\)
mu0, eps0 = 1.25663706212e-6, 8.8541878128e-12
print(f'{1/(mu0*eps0)**0.5:,.3f} m/s')