python - Finding max and min value every N rows in columns of CSV data -
i have csv file looks ~5m rows:
11/8/2016 2.495418222 2.501995109 2.488331492 2.504259694 11/8/2016 2.495759632 1.213707641 2.137418322 2.501118589 11/8/2016 2.495565218 3.050992103 0.870950956 2.500971719 11/8/2016 2.494934557 2.500041484 2.489212707 2.455110626
i trying find both max , min values of 10000-row sample, , iterate until end of data. (finding trend of multiple max , mins). code grabs value every 10000 rows instead of require above.
lcd = pan.read_csv('daq_test_2016-08-11.csv',usecols=[0,2,3,4,5],skiprows=[0,1,2],na_filter=false) lcd = np.array(lcd) tslen2 = len(lcd[:,0]) rph2 = 57600 sfr2 = tslen2/((tslen2/rph2)*(2)) currentdata = (lcd[0::sfr2])
you can try this:
lcd = pan.read_csv('daq_test_2016-08-11.csv',usecols=[0,2,3,4,5],skiprows=[0,1,2],na_filter=false) # group every 10,000 rows groups = lcd.groupby(pd.cut(lcd.index, range(0,len(lcd), 10000))) groups.min() groups.max()
Comments
Post a Comment