0

I have a csv file that is continuously updated by tickdata from a server. i want to arrange them into a 5 min resampled dataframe. i am currently using following code to resample resample_data_live = liveData['bid'].resample(timeframe, label='left').ohlc(). This is resampling fine for me. But it is adding a row in the end that is not completed 5 mins (one sample was there for the next time period in the csv). I want to skip that one or two sample to the dataframe. i have seen the question here but counting is not an option for me as the number of sample in 5 min time period is not constant.

2021-09-28 11:40:00.343512,1734.141,1734.141
2021-09-28 11:40:01.247292,1734.11,1734.11
2021-09-28 11:40:02.550210,1734.096,1734.096
2021-09-28 11:40:04.714733,1734.074,1734.074
2021-09-28 11:40:05.939508,1734.071,1734.071
2021-09-28 11:40:06.914511,1734.077,1734.077
2021-09-28 11:40:08.122761,1734.027,1734.027
2021-09-28 11:40:08.449462,1734.058,1734.058
2021-09-28 11:40:09.810694,1734.066,1734.066
2021-09-28 11:40:10.966345,1734.05,1734.05
2021-09-28 11:40:12.356883,1733.991,1733.991
2021-09-28 11:40:12.606795,1733.961,1733.961
2021-09-28 11:40:13.841166,1733.934,1733.934
2021-09-28 11:40:15.309823,1733.943,1733.943
2021-09-28 11:40:16.106648,1733.974,1733.974
2021-09-28 11:40:17.372195,1733.977,1733.977
2021-09-28 11:40:21.137584,1733.982,1733.982
2021-09-28 11:40:22.434377,1733.985,1733.985
2021-09-28 11:40:23.574931,1733.983,1733.983
2021-09-28 11:40:24.699860,1733.916,1733.916
2021-09-28 11:40:25.786482,1733.913,1733.913
2021-09-28 11:40:28.536309,1733.911,1733.911
2021-09-28 11:40:29.520623,1733.91,1733.91
2021-09-28 11:40:30.739297,1733.911,1733.911
2021-09-28 11:40:31.942347,1733.921,1733.921
2021-09-28 11:40:32.114171,1733.891,1733.891
2021-09-28 11:40:33.984276,1733.857,1733.857
2021-09-28 11:40:36.256643,1733.861,1733.861
2021-09-28 11:40:39.427170,1733.862,1733.862
2021-09-28 11:40:40.636756,1733.906,1733.906
2021-09-28 11:40:42.213878,1733.899,1733.899
2021-09-28 11:40:43.221112,1733.892,1733.892
2021-09-28 11:40:43.578257,1734.016,1734.016
2021-09-28 11:40:44.061272,1734.08,1734.08
2021-09-28 11:40:44.294940,1734.209,1734.209
2021-09-28 11:40:45.332500,1734.227,1734.227
2021-09-28 11:40:46.344212,1734.197,1734.197
2021-09-28 11:40:47.555498,1734.199,1734.199
2021-09-28 11:40:48.735057,1734.202,1734.202
2021-09-28 11:40:49.312164,1734.172,1734.172
2021-09-28 11:40:51.749400,1734.205,1734.205
2021-09-28 11:40:52.338842,1734.299,1734.299
2021-09-28 11:40:53.621852,1734.316,1734.316
2021-09-28 11:40:54.504427,1734.376,1734.376
2021-09-28 11:40:55.574584,1734.383,1734.383
2021-09-28 11:40:55.838334,1734.415,1734.415
2021-09-28 11:40:56.321584,1734.447,1734.447
2021-09-28 11:40:56.632708,1734.416,1734.416
2021-09-28 11:40:56.848371,1734.385,1734.385
2021-09-28 11:40:57.917772,1734.374,1734.374
2021-09-28 11:40:58.801454,1734.438,1734.438
2021-09-28 11:40:59.190159,1734.469,1734.469
2021-09-28 11:41:02.557379,1734.458,1734.458
2021-09-28 11:41:03.766967,1734.48,1734.48
2021-09-28 11:41:04.803265,1734.488,1734.488
2021-09-28 11:41:06.333969,1734.518,1734.518
2021-09-28 11:41:07.616432,1734.495,1734.495
2021-09-28 11:41:08.702254,1734.47,1734.47
2021-09-28 11:41:12.195610,1734.466,1734.466
2021-09-28 11:41:13.697412,1734.462,1734.462
2021-09-28 11:41:14.733622,1734.461,1734.461
2021-09-28 11:41:19.441093,1734.491,1734.491
2021-09-28 11:41:20.185859,1734.555,1734.555
2021-09-28 11:41:21.255442,1734.516,1734.516
2021-09-28 11:41:21.766152,1734.485,1734.485
2021-09-28 11:41:22.913674,1734.481,1734.481
2021-09-28 11:41:23.919523,1734.479,1734.479
2021-09-28 11:41:26.790011,1734.437,1734.437
2021-09-28 11:41:27.890294,1734.42,1734.42
2021-09-28 11:41:29.758423,1734.516,1734.548
2021-09-28 11:41:31.785814,1734.569,1734.569
2021-09-28 11:41:32.143117,1734.661,1734.661
2021-09-28 11:41:32.378902,1734.661,1734.661
2021-09-28 11:41:33.446770,1734.686,1734.686
2021-09-28 11:41:34.175182,1734.654,1734.654
2021-09-28 11:41:35.611386,1734.634,1734.634
2021-09-28 11:41:36.245572,1734.664,1734.664
2021-09-28 11:41:37.668843,1734.68,1734.68
2021-09-28 11:41:39.061001,1734.686,1734.686
2021-09-28 11:41:40.190421,1734.684,1734.684
2021-09-28 11:41:41.383291,1734.671,1734.671
2021-09-28 11:41:42.019879,1734.61,1734.61
2021-09-28 11:41:42.797615,1734.546,1734.546
2021-09-28 11:41:43.465491,1734.577,1734.577
2021-09-28 11:41:44.752125,1734.58,1734.58
2021-09-28 11:41:45.186132,1734.611,1734.611
2021-09-28 11:41:45.436673,1734.477,1734.477
2021-09-28 11:41:47.298703,1734.473,1734.473
2021-09-28 11:41:48.631085,1734.5,1734.532
2021-09-28 11:41:48.785962,1734.595,1734.626
2021-09-28 11:41:49.749165,1734.656,1734.656
2021-09-28 11:41:50.260029,1734.687,1734.687
2021-09-28 11:41:50.756106,1734.656,1734.656
2021-09-28 11:41:52.200933,1734.664,1734.664
2021-09-28 11:41:53.068841,1734.634,1734.601
2021-09-28 11:41:53.583921,1734.632,1734.632
2021-09-28 11:41:54.651328,1734.661,1734.661
2021-09-28 11:41:55.824651,1734.647,1734.613
2021-09-28 11:41:56.089944,1734.257,1734.257
2021-09-28 11:41:56.197757,1734.162,1734.162
2021-09-28 11:41:56.589752,1734.226,1734.257
2021-09-28 11:41:56.753055,1734.287,1734.287
2021-09-28 11:41:57.413658,1734.35,1734.35
2021-09-28 11:41:58.525480,1734.385,1734.416
2021-09-28 11:41:58.684392,1734.417,1734.417
2021-09-28 11:41:59.724529,1734.391,1734.391
2021-09-28 11:42:00.701920,1734.422,1734.422
2021-09-28 11:42:01.057869,1734.42,1734.42
2021-09-28 11:42:01.169393,1734.483,1734.483
2021-09-28 11:42:02.514548,1734.486,1734.486
2021-09-28 11:42:03.735962,1734.414,1734.382
2021-09-28 11:42:03.892774,1734.351,1734.351
2021-09-28 11:42:05.253519,1734.358,1734.358
2021-09-28 11:42:05.889614,1734.607,1734.607
2021-09-28 11:42:06.401885,1734.639,1734.639
2021-09-28 11:42:06.835221,1734.701,1734.701
2021-09-28 11:42:07.208400,1734.635,1734.635
2021-09-28 11:42:07.504399,1734.605,1734.605
2021-09-28 11:42:08.002508,1734.511,1734.511
2021-09-28 11:42:08.315349,1734.541,1734.541
2021-09-28 11:42:09.768330,1734.584,1734.584
2021-09-28 11:42:10.234615,1734.648,1734.68
2021-09-28 11:42:11.314361,1734.653,1734.653
2021-09-28 11:42:12.568502,1734.648,1734.648
2021-09-28 11:42:12.834832,1734.618,1734.618
2021-09-28 11:42:13.424011,1734.649,1734.649
2021-09-28 11:42:13.903933,1734.616,1734.616
2021-09-28 11:42:15.203224,1734.605,1734.605
2021-09-28 11:42:15.532722,1734.635,1734.635
2021-09-28 11:42:15.798532,1734.665,1734.665
2021-09-28 11:42:16.791236,1734.674,1734.674
2021-09-28 11:42:18.753536,1734.767,1734.767
2021-09-28 11:42:18.877911,1734.836,1734.836
2021-09-28 11:42:19.158562,1734.867,1734.867
2021-09-28 11:42:19.793133,1734.898,1734.898
2021-09-28 11:42:20.226828,1734.959,1734.959
2021-09-28 11:42:22.334455,1734.949,1734.949
2021-09-28 11:42:23.464619,1735.015,1735.015
2021-09-28 11:42:23.794075,1735.109,1735.109
2021-09-28 11:42:24.071924,1735.14,1735.14
2021-09-28 11:42:24.693990,1735.201,1735.201
2021-09-28 11:42:24.992562,1735.297,1735.297
2021-09-28 11:42:25.518699,1735.265,1735.265
2021-09-28 11:42:25.922477,1735.296,1735.327
2021-09-28 11:42:26.280492,1735.358,1735.358
2021-09-28 11:42:27.902617,1735.359,1735.359
2021-09-28 11:42:28.645380,1735.425,1735.455
2021-09-28 11:42:29.744971,1735.47,1735.47
2021-09-28 11:42:30.843214,1735.487,1735.487
2021-09-28 11:42:31.895655,1735.475,1735.475
2021-09-28 11:42:32.424709,1735.404,1735.404
2021-09-28 11:42:33.461904,1735.398,1735.398
2021-09-28 11:42:34.728892,1735.463,1735.463
2021-09-28 11:42:35.287317,1735.56,1735.56
2021-09-28 11:42:36.138692,1735.591,1735.591
2021-09-28 11:42:37.516051,1735.612,1735.612
2021-09-28 11:42:38.550962,1735.6,1735.6
2021-09-28 11:42:38.957318,1735.57,1735.57
2021-09-28 11:42:39.500293,1735.507,1735.507
2021-09-28 11:42:40.601929,1735.496,1735.496
2021-09-28 11:42:40.732954,1735.463,1735.463
2021-09-28 11:42:41.518346,1735.494,1735.494
2021-09-28 11:42:42.711627,1735.504,1735.504
2021-09-28 11:42:42.960714,1735.537,1735.537
2021-09-28 11:42:44.074907,1735.584,1735.584
2021-09-28 11:42:45.975201,1735.658,1735.658
2021-09-28 11:42:46.100433,1735.689,1735.689
2021-09-28 11:42:46.659169,1735.721,1735.721
2021-09-28 11:42:47.695713,1735.695,1735.695
2021-09-28 11:42:48.103223,1735.664,1735.664
2021-09-28 11:42:48.190946,1735.633,1735.633
2021-09-28 11:42:49.051822,1735.571,1735.571
2021-09-28 11:42:49.194538,1735.473,1735.473
2021-09-28 11:42:50.369551,1735.469,1735.469
2021-09-28 11:42:51.624217,1735.523,1735.523
2021-09-28 11:42:52.367567,1735.583,1735.583
2021-09-28 11:42:52.482421,1735.553,1735.553
2021-09-28 11:42:53.684895,1735.55,1735.55
2021-09-28 11:42:54.847495,1735.49,1735.49
2021-09-28 11:42:56.191835,1735.486,1735.486
2021-09-28 11:42:56.703142,1735.516,1735.516
2021-09-28 11:42:57.308180,1735.651,1735.651
2021-09-28 11:42:57.404148,1735.683,1735.683
2021-09-28 11:42:57.685212,1735.713,1735.713
2021-09-28 11:42:59.358958,1735.709,1735.709
2021-09-28 11:43:00.085188,1735.645,1735.645
2021-09-28 11:43:00.476017,1735.676,1735.676
2021-09-28 11:43:00.756246,1735.646,1735.646
2021-09-28 11:43:01.748115,1735.666,1735.666
2021-09-28 11:43:02.849244,1735.668,1735.668
2021-09-28 11:43:03.222719,1735.7,1735.7
2021-09-28 11:43:03.888706,1735.764,1735.764
2021-09-28 11:43:05.124410,1735.774,1735.774
2021-09-28 11:43:06.162074,1735.786,1735.786
2021-09-28 11:43:06.842518,1735.754,1735.754
2021-09-28 11:43:07.909913,1735.777,1735.777
2021-09-28 11:43:08.608213,1735.811,1735.841
2021-09-28 11:43:08.764336,1735.872,1735.872
2021-09-28 11:43:11.112973,1735.879,1735.879
2021-09-28 11:43:12.411679,1735.871,1735.871
2021-09-28 11:43:12.721443,1735.809,1735.777
2021-09-28 11:43:13.587127,1735.869,1735.869
2021-09-28 11:43:14.625604,1735.868,1735.868
2021-09-28 11:43:16.033607,1736.019,1736.019
2021-09-28 11:43:16.235128,1736.079,1736.079
2021-09-28 11:43:16.978891,1736.049,1736.049
2021-09-28 11:43:17.257922,1736.016,1736.016
2021-09-28 11:43:18.621240,1736.003,1736.003
2021-09-28 11:43:19.669702,1736.012,1736.012
2021-09-28 11:43:20.445327,1736.074,1736.074
2021-09-28 11:43:21.538562,1736.091,1736.091
2021-09-28 11:43:22.969512,1735.992,1735.992
2021-09-28 11:43:23.068455,1735.927,1735.927
2021-09-28 11:43:24.072044,1735.914,1735.914
2021-09-28 11:43:24.491321,1735.945,1735.945
2021-09-28 11:43:25.899505,1735.937,1735.937
2021-09-28 11:43:27.201285,1735.924,1735.924
2021-09-28 11:43:27.512575,1735.892,1735.859
2021-09-28 11:43:27.597599,1735.89,1735.89
2021-09-28 11:43:28.028059,1735.921,1735.921
2021-09-28 11:43:28.540115,1735.986,1735.986
2021-09-28 11:43:28.697029,1736.016,1736.016
2021-09-28 11:43:29.084162,1736.085,1736.085
2021-09-28 11:43:30.125172,1736.084,1736.084
2021-09-28 11:43:30.761373,1735.986,1735.986
2021-09-28 11:43:31.755200,1736.006,1736.006
2021-09-28 11:43:32.219303,1735.975,1735.975
2021-09-28 11:43:32.344660,1735.944,1735.944
2021-09-28 11:43:33.380637,1735.967,1735.967
2021-09-28 11:43:34.389161,1735.977,1735.977
2021-09-28 11:43:34.622408,1735.946,1735.946
2021-09-28 11:43:35.968931,1735.921,1735.921
2021-09-28 11:43:36.265131,1735.983,1735.983
2021-09-28 11:43:37.238206,1736.143,1736.143
2021-09-28 11:43:37.348201,1736.173,1736.173
2021-09-28 11:43:38.698335,1736.177,1736.177
2021-09-28 11:43:40.351535,1736.189,1736.189
2021-09-28 11:43:41.389823,1736.203,1736.203
2021-09-28 11:43:41.887670,1736.277,1736.277
2021-09-28 11:43:42.200862,1736.246,1736.246
2021-09-28 11:43:43.254528,1736.219,1736.219
2021-09-28 11:43:44.289847,1736.214,1736.214
2021-09-28 11:43:44.727205,1736.182,1736.182
2021-09-28 11:43:45.824781,1736.206,1736.206
2021-09-28 11:43:46.522168,1736.176,1736.176
2021-09-28 11:43:46.895902,1736.206,1736.206
2021-09-28 11:43:48.387623,1736.231,1736.231
2021-09-28 11:43:49.766203,1736.237,1736.237
2021-09-28 11:43:50.865176,1736.238,1736.238
2021-09-28 11:43:52.953032,1736.234,1736.234
2021-09-28 11:43:56.183538,1736.228,1736.228
2021-09-28 11:43:56.681736,1736.323,1736.323
2021-09-28 11:43:57.718349,1736.334,1736.334
2021-09-28 11:43:58.787917,1736.293,1736.293
2021-09-28 11:44:00.243268,1736.231,1736.231
2021-09-28 11:44:00.986211,1736.2,1736.2
2021-09-28 11:44:01.747015,1736.168,1736.168
2021-09-28 11:44:02.105378,1736.044,1736.044
2021-09-28 11:44:03.116328,1736.022,1736.022
2021-09-28 11:44:03.520825,1736.086,1736.086
2021-09-28 11:44:04.603305,1736.11,1736.11
2021-09-28 11:44:05.071151,1736.206,1736.206
2021-09-28 11:44:06.822666,1736.216,1736.216
2021-09-28 11:44:07.856097,1736.186,1736.186
2021-09-28 11:44:08.185190,1736.156,1736.156
2021-09-28 11:44:08.464351,1736.125,1736.125
2021-09-28 11:44:09.702628,1736.103,1736.103
2021-09-28 11:44:11.031762,1736.104,1736.104
2021-09-28 11:44:13.768286,1736.077,1736.077
2021-09-28 11:44:15.049197,1736.076,1736.076
2021-09-28 11:44:16.189445,1736.089,1736.089
2021-09-28 11:44:17.688107,1736.096,1736.096
2021-09-28 11:44:18.139893,1736.126,1736.126
2021-09-28 11:44:18.467512,1736.19,1736.19
2021-09-28 11:44:19.444619,1736.191,1736.191
2021-09-28 11:44:20.231896,1736.222,1736.222
2021-09-28 11:44:20.804364,1736.282,1736.282
2021-09-28 11:44:21.934797,1736.291,1736.291
2021-09-28 11:44:22.942108,1736.285,1736.285
2021-09-28 11:44:24.196261,1736.361,1736.361
2021-09-28 11:44:24.833683,1736.331,1736.331
2021-09-28 11:44:25.113384,1736.299,1736.299
2021-09-28 11:44:26.072853,1736.283,1736.283
2021-09-28 11:44:27.110845,1736.275,1736.275
2021-09-28 11:44:27.358631,1736.337,1736.337
2021-09-28 11:44:28.644599,1736.343,1736.343
2021-09-28 11:44:29.727047,1736.359,1736.359
2021-09-28 11:44:31.614953,1736.366,1736.366
2021-09-28 11:44:32.761422,1736.374,1736.374
2021-09-28 11:44:33.829733,1736.36,1736.36
2021-09-28 11:44:34.864063,1736.33,1736.33
2021-09-28 11:44:38.171786,1736.338,1736.338
2021-09-28 11:44:38.379407,1736.369,1736.369
2021-09-28 11:44:39.411937,1736.343,1736.343
2021-09-28 11:44:40.388902,1736.36,1736.36
2021-09-28 11:44:41.596854,1736.383,1736.383
2021-09-28 11:44:41.952635,1736.352,1736.352
2021-09-28 11:44:43.143503,1736.363,1736.363
2021-09-28 11:44:45.243727,1736.371,1736.371
2021-09-28 11:44:46.326990,1736.354,1736.354
2021-09-28 11:44:46.667864,1736.323,1736.323
2021-09-28 11:44:47.656085,1736.325,1736.325
2021-09-28 11:44:48.446101,1736.293,1736.293
2021-09-28 11:44:48.989511,1736.263,1736.263
2021-09-28 11:44:49.225990,1736.201,1736.201
2021-09-28 11:44:49.785768,1736.171,1736.171
2021-09-28 11:44:50.826153,1736.178,1736.178
2021-09-28 11:44:51.155013,1736.208,1736.208
2021-09-28 11:44:52.486423,1736.22,1736.22
2021-09-28 11:44:53.494846,1736.195,1736.195
2021-09-28 11:44:54.639854,1736.18,1736.18
2021-09-28 11:44:54.750285,1736.211,1736.211
2021-09-28 11:44:56.159001,1736.146,1736.146
2021-09-28 11:44:57.148770,1736.132,1736.132
2021-09-28 11:44:57.654268,1736.068,1736.038
2021-09-28 11:45:00.239191,1735.962,1735.962

i am expecting to have one row here. as: ignoring that one sample in the end

2021-09-28 11:40:00,1734.141,1736.383,1733.857,1736.068
Alex Waygood
  • 4,796
  • 3
  • 14
  • 41

0 Answers0