One-liners to combine Time-Series data into different intervals like based on each hour, week, or a month.

If you have ever dealt with Time-Series data analysis, you would have come across these problems for sure —

  1. Combining data into certain intervals like based on each day, a week, or a month.
  2. Aggregating data in the time interval like if you are dealing with price data then problems like total amount added in an hour, or a day.
  3. Finding patterns for other features in the dataset based on a time interval.

In this article, you will learn about how you can solve these problems with just one-line of code using only 2 different Pandas API’s i.e. resample() and Grouper().

As we know, the best way to learn something is to start applying it. So, I am going to use a sample time-series dataset provided by World Bank Open data and is related to the crowd-sourced price data collected from 15 countries. For more details about the data, refer Crowdsourced Price Data Collection Pilot. For this exercise, we are going to use data collected for Argentina.

#programming #data-science #pandas #python #data-analysis

How to group data by time intervals in Python Pandas?
17.05 GEEK