Home > Net >  Pandas functions every minute using python
Pandas functions every minute using python

Time:06-18

I need to get the max and the min Niveau every hour using python I have an idea but it's not working like I want it give

The code I wrote

import pandas as pd
df=pd.read_csv('Cmaregraphe.csv', sep='[;\s] ', engine='python')
a=df['Niveau'].max()

'''print('max niveau est : ' , a, 'durant la date : ', b )'''
print(df. groupby('Heure').mean())

My Cmaregraphe.csv

Contain 10366 lines here just a caption of it

Date ; Hour; Niveau         
02/01/2020;00:00:00;3.75        
02/01/2020;00:00:00;3.75        
02/01/2020;00:00:00;3.75        
02/01/2020;00:00:00;3.75        
02/01/2020;00:00:00;3.75        
02/01/2020;00:00:00;3.75        
02/01/2020;00:00:00;3.75        
02/01/2020;00:00:00;3.75        
02/01/2020;00:00:00;3.75        
02/01/2020;00:00:00;3.77        
02/01/2020;00:00:00;3.75        
02/01/2020;00:00:00;3.75        
02/01/2020;00:01:00;3.75        
02/01/2020;00:01:00;3.75        
02/01/2020;00:01:00;3.75        
02/01/2020;00:01:00;3.75        
02/01/2020;00:01:00;3.75        
02/01/2020;00:01:00;3.77        
02/01/2020;00:01:00;3.75        
02/01/2020;00:01:00;3.75        
02/01/2020;00:01:00;3.75        
02/01/2020;00:01:00;3.75        
02/01/2020;00:01:00;3.75        
02/01/2020;00:01:00;3.75        
02/01/2020;00:02:00;3.75        
02/01/2020;00:02:00;3.75        
02/01/2020;00:02:00;3.75        
02/01/2020;00:02:00;3.75        
02/01/2020;00:02:00;3.75        
02/01/2020;00:02:00;3.77        
02/01/2020;00:02:00;3.77        
02/01/2020;00:02:00;3.77        
02/01/2020;00:02:00;3.75        
02/01/2020;00:02:00;3.75        
02/01/2020;00:02:00;3.77        
02/01/2020;00:02:00;3.77        
02/01/2020;00:03:00;3.77        
02/01/2020;00:03:00;3.75        
02/01/2020;00:03:00;3.75        
02/01/2020;00:03:00;3.75        
02/01/2020;00:03:00;3.75        
02/01/2020;00:03:00;3.77        
02/01/2020;00:03:00;3.75        
02/01/2020;00:03:00;3.75        
02/01/2020;00:03:00;3.75        
02/01/2020;00:03:00;3.75        
02/01/2020;00:03:00;3.75        
02/01/2020;00:03:00;3.75        
02/01/2020;00:04:00;3.75        
02/01/2020;00:04:00;3.75        
02/01/2020;00:04:00;3.75        
02/01/2020;00:04:00;3.75        
02/01/2020;00:04:00;3.75        
02/01/2020;00:04:00;3.75        
02/01/2020;00:04:00;3.75        
02/01/2020;00:04:00;3.75        
02/01/2020;00:04:00;3.77        
02/01/2020;00:04:00;3.77        
02/01/2020;00:04:00;3.75        
02/01/2020;00:04:00;3.75        
02/01/2020;00:05:00;3.77        
02/01/2020;00:05:00;3.77        
02/01/2020;00:05:00;3.75        
02/01/2020;00:05:00;3.75        
02/01/2020;00:05:00;3.75        
02/01/2020;00:05:00;3.75        
02/01/2020;00:05:00;3.75        
02/01/2020;00:05:00;3.75        
02/01/2020;00:05:00;3.75        
02/01/2020;00:05:00;3.77        
02/01/2020;00:05:00;3.77        
02/01/2020;00:05:00;3.77        
02/01/2020;00:06:00;3.75        
02/01/2020;00:06:00;3.77        
02/01/2020;00:06:00;3.75        
02/01/2020;00:06:00;3.75        
02/01/2020;00:06:00;3.75        
02/01/2020;00:06:00;3.75        
02/01/2020;00:06:00;3.75        
02/01/2020;00:06:00;3.75        
02/01/2020;00:06:00;3.75        
02/01/2020;00:06:00;3.75        
02/01/2020;00:06:00;3.75        
02/01/2020;00:06:00;3.77        
02/01/2020;00:07:00;3.75        
02/01/2020;00:07:00;3.75        
02/01/2020;00:07:00;3.75        
02/01/2020;00:07:00;3.75        
02/01/2020;00:07:00;3.75        
02/01/2020;00:07:00;3.75        
02/01/2020;00:07:00;3.75        
02/01/2020;00:07:00;3.75        
02/01/2020;00:07:00;3.77        
02/01/2020;00:07:00;3.75        
02/01/2020;00:07:00;3.75        
02/01/2020;00:07:00;3.75        
02/01/2020;00:08:00;3.75        
02/01/2020;00:08:00;3.75        
02/01/2020;00:08:00;3.75        
02/01/2020;00:08:00;3.75        
02/01/2020;00:08:00;3.75        
02/01/2020;00:08:00;3.77        
02/01/2020;00:08:00;3.77        
02/01/2020;00:08:00;3.75        
02/01/2020;00:08:00;3.75        
02/01/2020;00:08:00;3.75        
02/01/2020;00:08:00;3.75        
02/01/2020;00:08:00;3.75        
02/01/2020;00:09:00;3.75        
02/01/2020;00:09:00;3.75        

CodePudding user response:

Here is one way to do it

df.groupby(['Date','Hour'])['Niveau'].agg(['min', 'max'])
                        min     max
Date        Hour        
02/01/2020  00:00:00    3.75    3.77
            00:01:00    3.75    3.77
            00:02:00    3.75    3.77
            00:03:00    3.75    3.77
            00:04:00    3.75    3.77
            00:05:00    3.75    3.77
            00:06:00    3.75    3.77
            00:07:00    3.75    3.77
            00:08:00    3.75    3.77
            00:09:00    3.75    3.75
  • Related