Is there any way pd. Grouper, how much used for time frequencies, adds lines even when there are no records in a time interval?

Asked

Viewed 63 times

0

I need to merge between two tables where the base table is grouped at 5 minute intervals, however in an interval that has no record to be grouped the corresponding row is not created

I am dealing with radar data in São Paulo and, for example, in the morning intervals, has less passage of cars, and often does not pass any, so that in the grouping this record of "empty" does not appear ;(

df_agregado = df_agregado.groupby([ 'Numero Agrupado',pd.Grouper(key='Data', freq='5Min')]).agg({ Registro": "count",Velocidade': 'mean'})

Expected result:

                       Registro   Velocidade
2018-01-03 00:00:00         nan          nan           
2018-01-03 08:05:00         nan          nan           
2018-01-03 08:10:00         nan          nan           
2018-01-03 08:15:00           5           22   
2018-01-03 08:20:00          10           31
2018-01-03 08:25:00         nan          nan

Result obtained:

                       Registro   Velocidade
2018-01-03 08:15:00           5           22   
2018-01-03 08:20:00          10           31

The test dataset is available here for Dataframe before and after grouping

Obs.: Note that between 1:50 and 2:00 there is no record of 1:55

  • You can provide an example dataset so that we can replicate your problem?

  • 1

    I just made available

2 answers

2


You can use the function asfreq of pandas

import pandas as pd
df = pd.read_csv('./Antes do Agrupamento.csv', parse_dates=['Data'])
df_agregado = df.groupby(['Numero Agrupado', pd.Grouper(key='Data', freq='5 min')]).agg({ "Registro": "count","Velocidade": 'mean'}).reset_index()

df_agregado.set_index('Data').asfreq('5 min').reset_index()
  1. Importing the pandas package
  2. Loading the data file
  3. Aggregating
  4. Data frame with frequency of 5 minutes

Exit:

          Data          Numero Agrupado    Registro Velocidade
    2018-01-03 00:00:00        10680          10    115,4
    2018-01-03 00:05:00        10680          13    123,2307692
    2018-01-03 00:10:00        10680          10    119,2
    2018-01-03 00:15:00        10680          12    116,0833333
    2018-01-03 00:20:00        10680          13    111,7692308
    2018-01-03 00:25:00        10680          17    121,8823529
    2018-01-03 00:30:00        10680          10    126,5
    2018-01-03 00:35:00        10680           9    117
    2018-01-03 00:40:00        10680          11    109,2727273
    2018-01-03 00:45:00        10680          12    114,1666667
    2018-01-03 00:50:00        10680           7    124,5714286
    2018-01-03 00:55:00        10680           9    116,1111111
    2018-01-03 01:00:00        10680           3    124,3333333
    2018-01-03 01:05:00        10680          10    117,4
    2018-01-03 01:10:00        10680           5    120,4
    2018-01-03 01:15:00        10680           5    128,4
    2018-01-03 01:20:00        10680           5    117,2
    2018-01-03 01:25:00        10680           4    123,5
    2018-01-03 01:30:00        10680           2    104
    2018-01-03 01:35:00        10680           5    121,8
    2018-01-03 01:40:00        10680           3    121,3333333
    2018-01-03 01:45:00        10680           3    123
    2018-01-03 01:50:00        10680           4    110,25
    2018-01-03 01:55:00          NaN          NaN   NaN
    .....           
  • 1

    Good. Simpler solution than mine. Consider upvote the question. Unfortunately, some troll downvoted a question well asked and relevant to the site. Reading recommendation: https://pt.meta.stackoverflow.com/questions/159/vote-cedo-vote-frequently

  • 1

    @Lucas I always vote, the Python community that doesn’t vote much. The R the crowd votes with force.

1

A solution is:

  1. Create an empty database;
  2. Place dates in this database that belong to the desired range but have no information;
  3. Fit with the original seat.

Follow code with this solution:

import pandas as pd
import numpy as np
pd.set_option('max.rows',500) #printar mais linha para checar se cóigo funcionou

df = pd.read_csv("antes_agrup.csv").iloc[:,1:]
df['Data']=pd.to_datetime(df["Data"])

df_agg = df.groupby(['Numero Agrupado',pd.Grouper(key='Data', freq='5Min')]).agg({ "Registro": "count","Velocidade": 'mean'})
df_agg.reset_index(inplace=True)

dates = df_agg['Data'].to_list()
dates.sort()

all_ranges = pd.date_range(start=dates[0], end=dates[-1],freq='5Min')
empty_ranges=[k for k in all_ranges if k not in dates]
cols=df_agg.columns.to_list()
cols.remove("Data")
empty = pd.DataFrame(columns = cols, index = empty_ranges)

df_agg.set_index('Data',drop=True,inplace=True)

df_agg = df_agg.append(empty)
df_agg.sort_index(inplace=True)

print(df_agg.iloc[:500,:])

Returns:

                   Numero Agrupado Registro  Velocidade
2018-01-03 00:00:00           10680       10  115.400000
2018-01-03 00:05:00           10680       13  123.230769
2018-01-03 00:10:00           10680       10  119.200000
2018-01-03 00:15:00           10680       12  116.083333
2018-01-03 00:20:00           10680       13  111.769231
2018-01-03 00:25:00           10680       17  121.882353
2018-01-03 00:30:00           10680       10  126.500000
2018-01-03 00:35:00           10680        9  117.000000
2018-01-03 00:40:00           10680       11  109.272727
2018-01-03 00:45:00           10680       12  114.166667
2018-01-03 00:50:00           10680        7  124.571429
2018-01-03 00:55:00           10680        9  116.111111
2018-01-03 01:00:00           10680        3  124.333333
2018-01-03 01:05:00           10680       10  117.400000
2018-01-03 01:10:00           10680        5  120.400000
2018-01-03 01:15:00           10680        5  128.400000
2018-01-03 01:20:00           10680        5  117.200000
2018-01-03 01:25:00           10680        4  123.500000
2018-01-03 01:30:00           10680        2  104.000000
2018-01-03 01:35:00           10680        5  121.800000
2018-01-03 01:40:00           10680        3  121.333333
2018-01-03 01:45:00           10680        3  123.000000
2018-01-03 01:50:00           10680        4  110.250000
2018-01-03 01:55:00             NaN      NaN         NaN
2018-01-03 02:00:00           10680        2  107.000000
2018-01-03 02:05:00           10680        3  122.000000
2018-01-03 02:10:00           10680        5  137.200000
2018-01-03 02:15:00           10680        2   87.500000
2018-01-03 02:20:00           10680        3  101.000000
2018-01-03 02:25:00           10680        2  129.500000
2018-01-03 02:30:00           10680        2  187.500000
2018-01-03 02:35:00           10680        2  127.500000
2018-01-03 02:40:00           10680        2  117.000000
2018-01-03 02:45:00             NaN      NaN         NaN
2018-01-03 02:50:00           10680        1  122.000000
2018-01-03 02:55:00           10680        2  118.000000
2018-01-03 03:00:00             NaN      NaN         NaN
2018-01-03 03:05:00           10680        3  113.000000
2018-01-03 03:10:00           10680        1  131.000000
2018-01-03 03:15:00           10680        1  131.000000
2018-01-03 03:20:00           10680        1  128.000000
2018-01-03 03:25:00           10680        3  117.666667
2018-01-03 03:30:00             NaN      NaN         NaN
2018-01-03 03:35:00           10680        2  122.000000
2018-01-03 03:40:00           10680        3  129.666667
2018-01-03 03:45:00             NaN      NaN         NaN
2018-01-03 03:50:00           10680        1  119.000000
2018-01-03 03:55:00           10680        3  135.333333
2018-01-03 04:00:00             NaN      NaN         NaN
2018-01-03 04:05:00           10680        3  113.000000
2018-01-03 04:10:00           10680        2  114.000000
2018-01-03 04:15:00           10680        1  108.000000
2018-01-03 04:20:00           10680        1  106.000000
2018-01-03 04:25:00           10680        3  126.000000
2018-01-03 04:30:00           10680        4  116.750000
2018-01-03 04:35:00           10680        3  120.000000
2018-01-03 04:40:00           10680        2  122.000000
2018-01-03 04:45:00           10680        4  118.000000
2018-01-03 04:50:00             NaN      NaN         NaN
2018-01-03 04:55:00           10680        5  121.600000
2018-01-03 05:00:00           10680        3  113.000000
2018-01-03 05:05:00           10680        5   98.200000
2018-01-03 05:10:00           10680        7  119.857143
2018-01-03 05:15:00           10680        4  123.500000
2018-01-03 05:20:00           10680        8  109.250000
2018-01-03 05:25:00           10680        6  110.500000
2018-01-03 05:30:00           10680       15  113.600000
2018-01-03 05:35:00           10680        9  114.777778
2018-01-03 05:40:00           10680        4  109.000000
2018-01-03 05:45:00           10680       14  109.928571
2018-01-03 05:50:00           10680        9  118.444444
2018-01-03 05:55:00           10680        9  114.444444
2018-01-03 06:00:00           10680        9  112.888889
2018-01-03 06:05:00           10680       10  117.100000
2018-01-03 06:10:00           10680        9  112.333333
2018-01-03 06:15:00           10680       18  111.444444
2018-01-03 06:20:00           10680       10  116.300000
2018-01-03 06:25:00           10680       17  107.000000
2018-01-03 06:30:00           10680       15  111.466667
2018-01-03 06:35:00           10680       12  111.583333
2018-01-03 06:40:00           10680       16  110.250000
2018-01-03 06:45:00           10680        8  113.125000
2018-01-03 06:50:00           10680       14  113.000000
2018-01-03 06:55:00           10680       21  116.619048
2018-01-03 07:00:00           10680        9  123.777778
2018-01-03 07:05:00           10680       17  115.117647
2018-01-03 07:10:00           10680       11  118.636364
2018-01-03 07:15:00           10680       15  112.933333
2018-01-03 07:20:00           10680       21  114.904762
2018-01-03 07:25:00           10680       15  113.466667
2018-01-03 07:30:00           10680       14  110.785714
2018-01-03 07:35:00           10680       20  108.250000
2018-01-03 07:40:00           10680       15  115.266667
2018-01-03 07:45:00           10680       23  106.304348
2018-01-03 07:50:00           10680       15  113.733333
2018-01-03 07:55:00           10680       28  113.392857
2018-01-03 08:00:00           10680       11  120.181818
2018-01-03 08:05:00           10680       28  111.357143
2018-01-03 08:10:00           10680       21  115.523810
2018-01-03 08:15:00           10680       20  108.550000
2018-01-03 08:20:00           10680       25  107.440000
2018-01-03 08:25:00           10680       20  114.450000
2018-01-03 08:30:00           10680       25  104.480000
2018-01-03 08:35:00           10680       29  109.896552
2018-01-03 08:40:00           10680       19  101.526316
2018-01-03 08:45:00           10680       25  105.400000
2018-01-03 08:50:00           10680       25  113.680000
2018-01-03 08:55:00           10680       26  108.500000
2018-01-03 09:00:00           10680       26  108.038462
2018-01-03 09:05:00           10680       33  106.818182
2018-01-03 09:10:00           10680       19  110.052632
2018-01-03 09:15:00           10680       25  112.200000
2018-01-03 09:20:00           10680       28  114.178571
2018-01-03 09:25:00           10680       25  114.120000
2018-01-03 09:30:00           10680       27  110.481481
2018-01-03 09:35:00           10680       27  114.222222
2018-01-03 09:40:00           10680       26  107.461538
2018-01-03 09:45:00           10680       41  111.926829
2018-01-03 09:50:00           10680       36  104.944444
2018-01-03 09:55:00           10680       26  109.461538
2018-01-03 10:00:00           10680       34   95.500000
2018-01-03 10:05:00           10680       45  100.177778
2018-01-03 10:10:00           10680       45   93.800000
2018-01-03 10:15:00           10680       25   97.960000
2018-01-03 10:20:00           10680       37  100.756757
2018-01-03 10:25:00           10680       23  101.130435
2018-01-03 10:30:00           10680       28   97.607143
2018-01-03 10:35:00           10680       38  100.052632
2018-01-03 10:40:00           10680       19  106.736842
2018-01-03 10:45:00           10680       32   94.125000
2018-01-03 10:50:00           10680       36   79.222222
2018-01-03 10:55:00           10680       31   90.225806
2018-01-03 11:00:00           10680       29  101.931034
2018-01-03 11:05:00           10680       28   98.428571
2018-01-03 11:10:00           10680       20  100.500000
2018-01-03 11:15:00           10680       31  103.322581
2018-01-03 11:20:00           10680       25   92.000000
2018-01-03 11:25:00           10680       26  102.884615
2018-01-03 11:30:00           10680       35   98.742857
2018-01-03 11:35:00           10680       21   89.238095
2018-01-03 11:40:00           10680       35   89.571429
2018-01-03 11:45:00           10680       41   84.536585
2018-01-03 11:50:00           10680       35   58.800000
2018-01-03 11:55:00           10680       20   50.900000
2018-01-03 12:00:00           10680       32   88.718750
2018-01-03 12:05:00           10680       35   89.257143
2018-01-03 12:10:00           10680       48   67.666667
2018-01-03 12:15:00           10680       36   49.805556
2018-01-03 12:20:00           10680       30   79.533333
2018-01-03 12:25:00           10680       36  100.472222
2018-01-03 12:30:00           10680       36   98.083333
2018-01-03 12:35:00           10680       24   90.875000
2018-01-03 12:40:00           10680       28   93.892857
2018-01-03 12:45:00           10680       32   97.031250
2018-01-03 12:50:00           10680       35   82.400000
2018-01-03 12:55:00           10680       28   95.928571
2018-01-03 13:00:00           10680       34   88.323529
2018-01-03 13:05:00           10680       35   95.257143
2018-01-03 13:10:00           10680       25   89.840000
2018-01-03 13:15:00           10680       33   98.606061
2018-01-03 13:20:00           10680       22   42.772727
2018-01-03 13:25:00           10680       43   58.023256
2018-01-03 13:30:00           10680       29   81.275862
2018-01-03 13:35:00           10680       30   71.833333
2018-01-03 13:40:00           10680       27   51.074074
2018-01-03 13:45:00           10680       33   84.242424
2018-01-03 13:50:00           10680       24   52.375000
2018-01-03 13:55:00           10680       27   37.444444
2018-01-03 14:00:00           10680       27   41.222222
2018-01-03 14:05:00           10680       33   25.727273
2018-01-03 14:10:00           10680       30   35.333333
2018-01-03 14:15:00           10680       23   44.652174
2018-01-03 14:20:00           10680       32   31.343750
2018-01-03 14:25:00           10680       34   52.411765
2018-01-03 14:30:00           10680       41   63.756098
2018-01-03 14:35:00           10680       26   26.500000
2018-01-03 14:40:00           10680       33   38.181818
2018-01-03 14:45:00           10680       23   28.739130
2018-01-03 14:50:00           10680       20   27.500000
2018-01-03 14:55:00           10680       22   20.500000
2018-01-03 15:00:00           10680       31   40.967742
2018-01-03 15:05:00           10680       23   22.173913
2018-01-03 15:10:00           10680       12   35.250000
2018-01-03 15:15:00           10680       31   41.838710
2018-01-03 15:20:00           10680       28   52.714286
2018-01-03 15:25:00           10680       24   61.416667
2018-01-03 15:30:00           10680       20   32.800000
2018-01-03 15:35:00           10680       19   28.789474
2018-01-03 15:40:00           10680       27   26.296296
2018-01-03 15:45:00           10680       33   27.787879
2018-01-03 15:50:00           10680       24   38.416667
2018-01-03 15:55:00           10680       13   23.846154
2018-01-03 16:00:00           10680       25   31.360000
2018-01-03 16:05:00           10680       30   24.100000
2018-01-03 16:10:00           10680       26   67.461538
2018-01-03 16:15:00           10680       24   91.833333
2018-01-03 16:20:00           10680       23  112.608696
2018-01-03 16:25:00           10680       30  119.366667
2018-01-03 16:30:00           10680       29  110.655172
2018-01-03 16:35:00           10680       22  115.227273
2018-01-03 16:40:00           10680       27   94.777778
2018-01-03 16:45:00           10680       13  103.384615
2018-01-03 16:50:00           10680       17  104.352941
2018-01-03 16:55:00           10680       26  115.576923
2018-01-03 17:00:00           10680       18  116.222222
2018-01-03 17:05:00           10680       24  119.541667
2018-01-03 17:10:00           10680       21  114.666667
2018-01-03 17:15:00           10680       16  112.937500
2018-01-03 17:20:00           10680       17  104.882353
2018-01-03 17:25:00           10680       30  108.833333
2018-01-03 17:30:00           10680       17  116.705882
2018-01-03 17:35:00           10680       36  108.361111
2018-01-03 17:40:00           10680       25  111.360000
2018-01-03 17:45:00           10680       34  113.823529
2018-01-03 17:50:00           10680       27  105.111111
2018-01-03 17:55:00           10680       33  105.969697
2018-01-03 18:00:00           10680       33  106.242424
2018-01-03 18:05:00           10680       24  116.125000
2018-01-03 18:10:00           10680       21  109.047619
2018-01-03 18:15:00           10680       37   80.135135
2018-01-03 18:20:00           10680       26  102.769231
2018-01-03 18:25:00           10680       39   85.025641
2018-01-03 18:30:00           10680       33   92.090909
2018-01-03 18:35:00           10680       17  118.235294
2018-01-03 18:40:00           10680       24  111.833333
2018-01-03 18:45:00           10680       28  110.857143
2018-01-03 18:50:00           10680       29  110.241379
2018-01-03 18:55:00           10680       31  108.483871
2018-01-03 19:00:00           10680       30  107.466667
2018-01-03 19:05:00           10680       23  114.391304
2018-01-03 19:10:00           10680       31  101.290323
2018-01-03 19:15:00           10680       33   94.121212
2018-01-03 19:20:00           10680       37   91.540541
2018-01-03 19:25:00           10680       34   92.058824
2018-01-03 19:30:00           10680       29   95.655172
2018-01-03 19:35:00           10680       46   91.413043
2018-01-03 19:40:00           10680       23  108.304348
2018-01-03 19:45:00           10680       21  117.714286
2018-01-03 19:50:00           10680       24  114.750000
2018-01-03 19:55:00           10680       26  109.423077
2018-01-03 20:00:00           10680       29  109.241379
2018-01-03 20:05:00           10680       25  105.400000
2018-01-03 20:10:00           10680       26  115.384615
2018-01-03 20:15:00           10680       41   99.487805
2018-01-03 20:20:00           10680       20  101.550000
2018-01-03 20:25:00           10680       28   99.071429
2018-01-03 20:30:00           10680       21  103.428571
2018-01-03 20:35:00           10680       31   91.322581
2018-01-03 20:40:00           10680       22  104.409091
2018-01-03 20:45:00           10680       24   97.166667
2018-01-03 20:50:00           10680       26  103.384615
2018-01-03 20:55:00           10680       28  101.928571
2018-01-03 21:00:00           10680       16  105.375000
2018-01-03 21:05:00           10680       23  104.913043
2018-01-03 21:10:00           10680        9  125.000000
2018-01-03 21:15:00           10680       13  114.615385
2018-01-03 21:20:00           10680       21  104.761905
2018-01-03 21:25:00           10680       15  116.000000
2018-01-03 21:30:00           10680       13  117.000000
2018-01-03 21:35:00           10680       23  110.521739
2018-01-03 21:40:00           10680       17  103.470588
2018-01-03 21:45:00           10680       15  119.600000
2018-01-03 21:50:00           10680       13  115.923077
2018-01-03 21:55:00           10680       10  117.900000
2018-01-03 22:00:00           10680       13  110.384615
2018-01-03 22:05:00           10680       16  116.250000
2018-01-03 22:10:00           10680       18  110.777778
2018-01-03 22:15:00           10680       23  111.826087
2018-01-03 22:20:00           10680       18  128.222222
2018-01-03 22:25:00           10680       19  121.736842
2018-01-03 22:30:00           10680       20  112.650000
2018-01-03 22:35:00           10680       17  116.176471
2018-01-03 22:40:00           10680       10  119.500000
2018-01-03 22:45:00           10680       17  121.941176
2018-01-03 22:50:00           10680        7  107.000000
2018-01-03 22:55:00           10680       10  115.000000
2018-01-03 23:00:00           10680       16  123.187500
2018-01-03 23:05:00           10680       19  110.421053
2018-01-03 23:10:00           10680       14  125.785714
2018-01-03 23:15:00           10680       11  115.909091
2018-01-03 23:20:00           10680       23  114.782609
2018-01-03 23:25:00           10680       15  110.066667
2018-01-03 23:30:00           10680       10  112.100000
2018-01-03 23:35:00           10680       15  113.733333
2018-01-03 23:40:00           10680       14  123.642857
2018-01-03 23:45:00           10680        9  111.555556
2018-01-03 23:50:00           10680       16  119.937500
2018-01-03 23:55:00           10680        1  114.000000
2018-01-04 00:00:00             NaN      NaN         NaN
2018-01-04 00:05:00             NaN      NaN         NaN
2018-01-04 00:10:00             NaN      NaN         NaN
2018-01-04 00:15:00             NaN      NaN         NaN
2018-01-04 00:20:00             NaN      NaN         NaN
2018-01-04 00:25:00             NaN      NaN         NaN
2018-01-04 00:30:00             NaN      NaN         NaN
2018-01-04 00:35:00             NaN      NaN         NaN
2018-01-04 00:40:00             NaN      NaN         NaN
2018-01-04 00:45:00             NaN      NaN         NaN
2018-01-04 00:50:00             NaN      NaN         NaN
2018-01-04 00:55:00             NaN      NaN         NaN
2018-01-04 01:00:00             NaN      NaN         NaN
2018-01-04 01:05:00             NaN      NaN         NaN
2018-01-04 01:10:00             NaN      NaN         NaN
2018-01-04 01:15:00             NaN      NaN         NaN
2018-01-04 01:20:00             NaN      NaN         NaN
2018-01-04 01:25:00             NaN      NaN         NaN
2018-01-04 01:30:00             NaN      NaN         NaN
2018-01-04 01:35:00             NaN      NaN         NaN
2018-01-04 01:40:00             NaN      NaN         NaN
2018-01-04 01:45:00             NaN      NaN         NaN
2018-01-04 01:50:00             NaN      NaN         NaN
2018-01-04 01:55:00             NaN      NaN         NaN
2018-01-04 02:00:00             NaN      NaN         NaN
2018-01-04 02:05:00             NaN      NaN         NaN
2018-01-04 02:10:00             NaN      NaN         NaN
2018-01-04 02:15:00             NaN      NaN         NaN
2018-01-04 02:20:00             NaN      NaN         NaN
2018-01-04 02:25:00             NaN      NaN         NaN
2018-01-04 02:30:00             NaN      NaN         NaN
2018-01-04 02:35:00             NaN      NaN         NaN
2018-01-04 02:40:00             NaN      NaN         NaN
2018-01-04 02:45:00             NaN      NaN         NaN
2018-01-04 02:50:00             NaN      NaN         NaN
2018-01-04 02:55:00             NaN      NaN         NaN
2018-01-04 03:00:00             NaN      NaN         NaN
2018-01-04 03:05:00             NaN      NaN         NaN
2018-01-04 03:10:00             NaN      NaN         NaN
2018-01-04 03:15:00             NaN      NaN         NaN
2018-01-04 03:20:00             NaN      NaN         NaN
2018-01-04 03:25:00             NaN      NaN         NaN
2018-01-04 03:30:00             NaN      NaN         NaN
2018-01-04 03:35:00             NaN      NaN         NaN
2018-01-04 03:40:00             NaN      NaN         NaN
2018-01-04 03:45:00             NaN      NaN         NaN
2018-01-04 03:50:00             NaN      NaN         NaN
2018-01-04 03:55:00             NaN      NaN         NaN
2018-01-04 04:00:00             NaN      NaN         NaN
2018-01-04 04:05:00             NaN      NaN         NaN
2018-01-04 04:10:00             NaN      NaN         NaN
2018-01-04 04:15:00             NaN      NaN         NaN
2018-01-04 04:20:00             NaN      NaN         NaN
2018-01-04 04:25:00             NaN      NaN         NaN
2018-01-04 04:30:00             NaN      NaN         NaN
2018-01-04 04:35:00             NaN      NaN         NaN
2018-01-04 04:40:00             NaN      NaN         NaN
2018-01-04 04:45:00             NaN      NaN         NaN
2018-01-04 04:50:00             NaN      NaN         NaN
2018-01-04 04:55:00             NaN      NaN         NaN
2018-01-04 05:00:00             NaN      NaN         NaN
2018-01-04 05:05:00             NaN      NaN         NaN
2018-01-04 05:10:00             NaN      NaN         NaN
2018-01-04 05:15:00             NaN      NaN         NaN
2018-01-04 05:20:00             NaN      NaN         NaN
2018-01-04 05:25:00             NaN      NaN         NaN
2018-01-04 05:30:00             NaN      NaN         NaN
2018-01-04 05:35:00             NaN      NaN         NaN
2018-01-04 05:40:00             NaN      NaN         NaN
2018-01-04 05:45:00             NaN      NaN         NaN
2018-01-04 05:50:00             NaN      NaN         NaN
2018-01-04 05:55:00             NaN      NaN         NaN
2018-01-04 06:00:00             NaN      NaN         NaN
2018-01-04 06:05:00             NaN      NaN         NaN
2018-01-04 06:10:00             NaN      NaN         NaN
2018-01-04 06:15:00             NaN      NaN         NaN
2018-01-04 06:20:00             NaN      NaN         NaN
2018-01-04 06:25:00             NaN      NaN         NaN
2018-01-04 06:30:00             NaN      NaN         NaN
2018-01-04 06:35:00             NaN      NaN         NaN
2018-01-04 06:40:00             NaN      NaN         NaN
2018-01-04 06:45:00             NaN      NaN         NaN
2018-01-04 06:50:00             NaN      NaN         NaN
2018-01-04 06:55:00             NaN      NaN         NaN
2018-01-04 07:00:00             NaN      NaN         NaN
2018-01-04 07:05:00             NaN      NaN         NaN
2018-01-04 07:10:00             NaN      NaN         NaN
2018-01-04 07:15:00             NaN      NaN         NaN
2018-01-04 07:20:00             NaN      NaN         NaN
2018-01-04 07:25:00             NaN      NaN         NaN
2018-01-04 07:30:00             NaN      NaN         NaN
2018-01-04 07:35:00             NaN      NaN         NaN
2018-01-04 07:40:00             NaN      NaN         NaN
2018-01-04 07:45:00             NaN      NaN         NaN
2018-01-04 07:50:00             NaN      NaN         NaN
2018-01-04 07:55:00             NaN      NaN         NaN
2018-01-04 08:00:00             NaN      NaN         NaN
2018-01-04 08:05:00             NaN      NaN         NaN
2018-01-04 08:10:00             NaN      NaN         NaN
2018-01-04 08:15:00             NaN      NaN         NaN
2018-01-04 08:20:00             NaN      NaN         NaN
2018-01-04 08:25:00             NaN      NaN         NaN
2018-01-04 08:30:00             NaN      NaN         NaN
2018-01-04 08:35:00             NaN      NaN         NaN
2018-01-04 08:40:00             NaN      NaN         NaN
2018-01-04 08:45:00             NaN      NaN         NaN
2018-01-04 08:50:00             NaN      NaN         NaN
2018-01-04 08:55:00             NaN      NaN         NaN
2018-01-04 09:00:00             NaN      NaN         NaN
2018-01-04 09:05:00             NaN      NaN         NaN
2018-01-04 09:10:00             NaN      NaN         NaN
2018-01-04 09:15:00             NaN      NaN         NaN
2018-01-04 09:20:00             NaN      NaN         NaN
2018-01-04 09:25:00             NaN      NaN         NaN
2018-01-04 09:30:00             NaN      NaN         NaN
2018-01-04 09:35:00             NaN      NaN         NaN
2018-01-04 09:40:00             NaN      NaN         NaN
2018-01-04 09:45:00             NaN      NaN         NaN
2018-01-04 09:50:00             NaN      NaN         NaN
2018-01-04 09:55:00             NaN      NaN         NaN
2018-01-04 10:00:00             NaN      NaN         NaN
2018-01-04 10:05:00             NaN      NaN         NaN
2018-01-04 10:10:00             NaN      NaN         NaN
2018-01-04 10:15:00             NaN      NaN         NaN
2018-01-04 10:20:00             NaN      NaN         NaN
2018-01-04 10:25:00             NaN      NaN         NaN
2018-01-04 10:30:00             NaN      NaN         NaN
2018-01-04 10:35:00             NaN      NaN         NaN
2018-01-04 10:40:00             NaN      NaN         NaN
2018-01-04 10:45:00             NaN      NaN         NaN
2018-01-04 10:50:00             NaN      NaN         NaN
2018-01-04 10:55:00             NaN      NaN         NaN
2018-01-04 11:00:00             NaN      NaN         NaN

Of course, you can replace the Nan by zero using df_agg.fillna(0)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.