Stage 2: Data toolkit · topic 7 of 47

SQL and Python for ESG analysts

Query and clean larger ESG datasets with SQL and pandas, and move repeatable calculations out of spreadsheets into tested, version-controlled code. You will rebuild a workbook in code and prove the totals match.

  • Optional
  • Intermediate
  • about 40 hours

Part of the ESG analyst roadmap: from the basics to mid level

Written by the GreenHired editorial teamSources last checked 20 November 2026How we research roadmaps

Rebuild something you already trust. Take the emissions workbook, redo the calculation in SQL or pandas, and compare the totals: the spreadsheet is your first test. Learn SQL first, then pandas, then tests and Git. Treat cloud platforms as an idea to understand, not a skill to master yet. A notebook that works on your laptop is not a production pipeline, and you are not expected to build one; repeating the work on a schedule is the subject of automation and AI in ESG.

A join that doubles a number

The emissions table says site 1 has 100 tonnes, site 2 has 200 and site 3 has 50, so 350 tonnes in total (made-up data). The sites table lists site 2 twice, because two people are named as its contact.

Join emissions to sites on site_id and sum by country, and site 2’s 200 tonnes now sits on two rows: 100 + 200 + 200 + 50 = 550 tonnes, which is 57% too high ((550 - 350) / 350). Nothing errors and the chart looks fine, which is how a doubled number reaches a dashboard.

Two habits catch this. Count rows before and after: the emissions table had 3 rows and the joined result has 4. In SQL, SELECT site_id, COUNT(*) FROM sites GROUP BY site_id HAVING COUNT(*) > 1 lists the duplicated keys. Then ask the tool to check: in pandas, sites.merge(emissions, on="site_id", validate="one_to_many") stops with a MergeError when the left table has repeated keys. The pandas user guide shows the same check.

The fix is to deduplicate the sites table, or to give the contacts their own table.

Using the spreadsheet as your test

  1. Calculate one site and one month by hand.
  2. Run the code and compare it with the workbook. If totals differ, find which is wrong. The difference is a finding: write it in your notes.
  3. Turn the hand calculation into a test, then add a test for a missing factor and one for a unit error, as in the practice task.
  4. Decide what a missing value means before the code runs. A blank filled with zero lowers the total.

Is this topic worth the hours?

It is optional on the map. If the roles you are aiming at name SQL or Python, treat it as core; if they do not, finish auditable spreadsheets first. In our sample of 16 job postings (UK, EU, US and India; how we research roadmaps), 6 named SQL (3 required it, 3 preferred it) and 4 named Python (2 required it, 2 preferred it). All three US postings named SQL.

What you will learn

  • Write SQL queries that filter, join and aggregate tables of site, supplier or emissions data.
  • Load, clean, merge and summarise datasets in Python with pandas.
  • Write small tests that prove an emissions calculation gives a known answer.
  • Keep work in notebooks and a Git repository so changes are visible and reversible.
  • Know what cloud data platforms such as Databricks and Snowflake are for, and how to read data from files and APIs.

The parts of this topic

SQL: SELECT, JOIN and GROUP BYabout 6 hours

Ask a database questions: filter rows, join tables on keys and total by group.

SQL queries a table with SELECT, narrows it with WHERE, combines tables with JOIN and totals with GROUP BY. Example: join an emissions table to a sites table on site_id and sum tonnes by country. A JOIN on a key that is not unique duplicates rows and inflates totals, so check the row count before and after every join. SQLZoo offers interactive practice in the browser.

pandas: load and clean dataabout 5 hours

Read CSV and Excel files, handle missing values and fix types so the data is ready to calculate.

pandas is Python's table library. It reads CSV and Excel files into a DataFrame, shows you missing values, and lets you fix column types, trim text and rename columns in a few lines. A supplier file with 'N/A' in a numeric column has to become a proper missing value before you can sum it. Filling missing values with zero without a word understates emissions. Decide what each gap means and record the choice.

pandas: merge and groupabout 5 hours

Combine activity data with emission factors and total by site, fuel or month.

A merge joins two tables on a key, like a lookup in Excel but for thousands of rows. A groupby splits a table into groups, applies a function such as sum and combines the result. For instance, merge a fuel-use table with a factors table on fuel type, multiply, then group by site. A many-to-many merge quietly multiplies rows. Ask pandas to validate the relationship (for example one-to-many, with the unique table on the left) so a bad key raises an error instead of a wrong total.

Tests for calculationsabout 5 hours

Write small automated checks that a calculation returns a known answer, and use AI coding helpers only with such checks.

A test runs your function on a small input with a known result and fails loudly if it changes. A test on one tonne of a fuel with a known factor must give the figure you calculated by hand. Tests catch broken unit conversions after you edit a file, and give reviewers confidence. If you use an AI coding assistant, treat its code like an unknown colleague's: run it against your tests, and do not paste confidential company data into an external tool without permission. Code that runs without errors can still be wrong.

Notebooks and Gitabout 4 hours

Keep exploratory work in notebooks and every change in version control, so a colleague can reproduce and review it.

A Jupyter notebook mixes code, results and notes in one document, which is ideal for exploring data and explaining a method. Git records every change to a project, lets you go back to an earlier version and shows who changed what. Before an assurance review, it lets you show the exact code and data that produced last year's figure. Git replaces files named final_v2_new.xlsx, and notebooks edited until nobody remembers how a result was produced. Commit small changes with a clear message.

Databricks and Snowflake awarenessabout 4 hours

What cloud data platforms do and why large ESG teams use them, without needing to be an engineer.

Cloud platforms such as Databricks and Snowflake store large datasets and run SQL or Python on them, with access controls and scheduled jobs. One US posting in the sample named Databricks. Databricks offers a Free Edition that its page describes as a way to learn data and AI tools for free. A company with hundreds of sites, for instance, loads meter data into a platform instead of emailing spreadsheets. You only need the idea at this stage: tables, queries, jobs and permissions. Learn the SQL underneath before the platform's buttons.

Reading data from APIs and open filesabout 4 hours

Pull public datasets and supplier files into code, and record where each came from.

Many sources publish data as CSV files or through web APIs. Python's requests library fetches them in a few lines, and pandas reads the result. Example: download Our World in Data's open CO2 dataset from its GitHub repository and compare a country's emissions across years. Record the URL, the date you downloaded it and the version, or the next person cannot repeat your result or tell whether the file changed. Store a small metadata note beside each downloaded file.

Practice task

Take the emissions workbook you built earlier and rebuild the calculation in Python: load the activity and factor tables with pandas, merge them, calculate tonnes CO2e by site and fuel, and write three tests (a known value, a missing factor, a unit error). Put the notebook and tests in a Git repository with a short README, and compare your totals with the spreadsheet.

Skills you build

SQL SELECT, JOIN, GROUP BYpandas loading, cleaning and mergingTesting calculationsNotebooks and GitReading data from APIs and files

Resources for this topic

Every source here is free. Each link opens the provider's own site in a new tab.

Back to the whole roadmap

Live jobs

Live ESG analyst jobs

Roles whose title matches this career path.

All ESG & Sustainability Reporting jobs

Spot a problem with this topic?

Tell us what is wrong, missing or unclear here. Your note is attached to this topic.

Notes are sent from this page with JavaScript on. Without it, write to us on the contact page.