简体   繁体   中英

Pandas functions every minute using python

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        

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM