Working with temporal properties using pandas Datetime Index

Leverage the properties of DatetimeIndex in Pandas for more efficient time series analysis, from formatting the column to creating reports with pivot tables.

The electricity generated by a photovoltaic solar plant varies significantly according to the hour and month.

Pivot table of solar energy generation by hour and month at a photovoltaic plant during the year 2023.
F1. Energy generation by hour and month in 2023

The energy generation at 18:00 is not the same as at 21:00, nor in January as in June.


The raw data represent solar energy generation at a photovoltaic plant over the course of the year 2023.

import pandas as pd

df = pd.read_csv('data.csv')
Raw data of solar energy generation at a photovoltaic plant throughout the year 2023.
F2. Raw solar energy data throughout 2023


To create the report from the raw data, we need to answer the following questions:

  1. How to format the temporal column with pandas?
  2. Why is it useful to set the temporal column as an index?
  3. How to create independent temporal columns?
  4. How to aggregate data based on hour and month?
  5. How to filter data relevant for analysis?
  6. What technique highlights the variation in energy generation throughout the day?

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to datons.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.