numpy – implement vectorization instead of nested Loops on dataframe

I have a dataset of the form below – timestamp,cell_id,crnti,enodeb_id,uplane_downlink.cqi_wideband_mean,uplane_downlink.distance_initial_km,uplane_downlink.non_gbr_dl_bytes,time_sec,timestamp_y,uplane_uplink.non_gbr_ul_bytes 1606208553171,1,1487,1002107,7,27,134,1606208553,1606208553256,146 1606208557195,1,1487,1002107,6,27,388,1606208557,1606208557369,577 1606208557236,1,2631,1002107,10,27,251,1606208557,1606208557351,194 1606208561301,1,1487,1002107,6,27,140,1606208561,1606208561463,245 1606208561339,1,2631,1002107,11,27,159,1606208561,1606208561381,108 1606208565415,1,1487,1002107,7,27,99,1606208565,1606208565472,54 1606208565435,1,2631,1002107,10,27,64,1606208565,1606208565495,54 1606208569518,1,1487,1002107,6,27,101,1606208569,1606208569601,289 1606208569533,1,2528,1002107,7,16,57,1606208569,1606208569621,0 1606208571263,1,2631,1002107,10,27,0,1606208571,1606208571263,8500 1606208573557,1,2528,1002107,8,16,0,1606208573,1606208573557,0 1606208575838,1,1487,1002107,7,27,0,1606208575,1606208575838,50 Here the column ‘crnti’ represents an user and…