KevsRobots Learning Platform
By Kevin McAleer, 3 Minutes

Time to put it all together. We’ll work through one complete example, from generating data to a chart, then give you some projects to try on your own.
Imagine your robot logs its battery level every hour for a week. We’ll use NumPy to make some realistic-looking data, then clean it, analyse it and chart it with Pandas.
pd.date_range() makes 168 hourly timestamps. NumPy builds a battery level that drains through each day (the robot is recharged every 24 hours) plus a little random noise. The seed means you’ll get the same numbers every timeNaN to pretend the sensor dropped outinterpolate() fills each gap with a value between its neighbours, which suits a smoothly changing reading like thisresample('D', on='time') groups the readings by day, and rolling(window=6).mean() averages each reading with the five before it, smoothing out the noiseplot() draws the raw and smoothed lines togetherDownload historical prices for a stock or cryptocurrency as a CSV file. Load it with read_csv(), parse the dates, and plot the closing price with 20-day and 50-day rolling averages.
Make a small CSV of survey answers with some blanks. Count missing values, fill or drop them, turn text answers like “Agree” into numbers with replace(), and use value_counts() to summarise each question.
Group a year of sales data by month with resample('MS'), plot the trend, and use a rolling average to estimate next month’s sales.
Log readings from a real sensor, such as a Raspberry Pi Pico’s temperature sensor, to a CSV file. Then load and analyse it with everything you’ve learned.
Quick quiz
Why does the worked example use rolling(window=6).mean()?
This lesson worked through a complete analysis, from raw data to a chart, and suggested real-world projects to practise on. Real data is the best teacher, so pick a project and dive in!
You can use the arrows ← → on your keyboard to navigate between lessons.
Comments