Head office, Rana Pratap Bagh, Delhi011 2721 1512+91 97116 99511

Science project idea

Python and pandas analysis of 30 years of monthly rainfall open data

Farmers and city planners ask whether the monsoon is changing. A student can download a public rainfall data set, clean it with pandas and plot monthly averages, yearly totals and a trend line, which teaches data cleaning, statistics and honest conclusions.

What it shows

Farmers and city planners ask whether the monsoon is changing. A student can download a public rainfall data set, clean it with pandas and plot monthly averages, yearly totals and a trend line, which teaches data cleaning, statistics and honest conclusions.

The science

Raw data have missing values, different formats and sometimes errors. Pandas reads the table, lets you drop or fill gaps, group by year or month, and compute means and totals. A linear fit of yearly rainfall against year gives a slope in mm per year, but a small slope inside the year-to-year variation is not proof of a real trend. A standard deviation or a rolling mean helps judge this.

Materials

Cost: free. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.

  • A laptop with Python 3, pandas, matplotlib and Jupyter or Thonny
  • A free monthly rainfall data set for an Indian district or state from an open government data portal or meteorological source (downloaded as CSV)
  • A notebook for the report
  • Internet only to download the data

Safety

For this project: Download data only from official public portals and check the licence terms. Back up your work regularly.

Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.

All the safety rules

Step by step

10 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.

  1. Download the CSV for your state or district and keep the raw file unchanged in a separate folder.

  2. Open it in pandas with read_csv, print the first rows, the columns and info() to see types and missing values.

  3. Clean the data: rename columns, convert the date, treat missing values as NaN and note how many there are.

  4. Group by month and find the mean rainfall for each month, then plot a bar chart that shows the monsoon peak.

  5. Group by year and sum, then plot yearly totals as a line chart with a 5-year rolling mean.

  6. Fit a straight line using numpy polyfit and draw it on the chart with its slope in mm per year.

  7. Find the three driest and three wettest years and compare them with known drought and flood years from news.

  8. Compute the percentage of yearly rainfall that falls in June to September.

  9. Write a short written interpretation that states the uncertainties, such as gaps and the length of the record.

  10. Save the notebook, the figures and a README that explains how to reproduce the analysis.

What you should see

The notebook shows a clear monsoon peak, a year-to-year variation of 20 percent or more, and a trend line whose slope is small compared with that variation. The report states clearly what the data can and cannot say.

Viva questions

A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.

1What is missing data and how did you handle it?

Months with no value. I counted them, did not invent numbers and calculated averages from the available data only.

2What does a rolling mean do?

It averages a few neighbouring years to smooth out random yearly changes.

3Does a negative slope prove climate change?

No. A trend must be larger than the natural variation and needs longer records and tests.

4Why keep the raw file untouched?

So the analysis can be repeated and any cleaning step can be checked.

Free ebook: Viva Questions for Science Projects

Take it further

Compare two districts and test whether their yearly rainfall changes are correlated using a correlation coefficient.

Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.

Free ebooks for this project

WhatsApp us