Python Forum
Most efficient way to roll through a pandas dataframe?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Most efficient way to roll through a pandas dataframe?
#1
See the below example of a pandas df.

Assumptions - The datetime index will ALWAYS be at 1 second interval

So I need a "rolling" window of this dataframe so that I can apply function custom_rolling(df) to each window. The window length will be determined by variable agg_seconds which is defined by me.

Example where agg_seconds = 10, I would need slices of the dataframe as follows:

2024-05-15 09:30:00-04:00 - 2024-05-15 09:30:09-04:00
2024-05-15 09:30:01-04:00 - 2024-05-15 09:30:10-04:00
2024-05-15 09:30:02-04:00 - 2024-05-15 09:30:11-04:00
2024-05-15 09:30:03-04:00 - 2024-05-15 09:30:12-04:00

etc....

Of course I can use a for loop to get these slices... but I really don't want to in the name of efficiency.

.resample won't work because a resample at say 10 seconds would give me windows of

2024-05-15 09:30:00-04:00 - 2024-05-15 09:30:09-04:00
2024-05-15 09:30:10-04:00 - 2024-05-15 09:30:19-04:00
2024-05-15 09:30:20-04:00 - 2024-05-15 09:30:29-04:00

which is not what I want.

I was thinking of using .rolling, as the index is a datetime... but .rolling only has a window length input parameter - I don't see a window step parameter. The step will always be 1 second - basically I way to take a 10 second window at a step of one second... so I'm not sure if .rolling can do it, or can it?

Another option is convert everything to numpy arrays and use numpy.lib.stride_tricks.sliding_window_view - but is converting everything to numpy arrays, and then using numpy.lib.stride_tricks.sliding_window_view better than a for loop?

Or is there another, more efficient way to do this?

Output:
open high low close volume vwap timestamp transactions dt 2024-05-15 09:30:00-04:00 179.9000 180.0000 179.8500 179.8900 477008 179.9033 1715779800000 794 2024-05-15 09:30:01-04:00 179.9580 179.9700 179.7000 179.7300 16827 179.8346 1715779801000 722 2024-05-15 09:30:02-04:00 179.8200 179.9000 179.6200 179.7080 18568 179.6983 1715779802000 544 2024-05-15 09:30:03-04:00 179.6500 179.9000 179.6000 179.6000 13147 179.7480 1715779803000 552 2024-05-15 09:30:04-04:00 179.6000 179.9000 179.5500 179.5740 10557 179.6424 1715779804000 521 2024-05-15 09:30:05-04:00 179.5500 179.9000 179.4000 179.4698 35924 179.5270 1715779805000 653 2024-05-15 09:30:06-04:00 179.4550 179.6900 179.3600 179.4495 10001 179.5017 1715779806000 229 2024-05-15 09:30:07-04:00 179.7600 179.7600 179.3600 179.4200 9487 179.4425 1715779807000 191 2024-05-15 09:30:08-04:00 179.3500 179.4950 179.3300 179.3584 15950 179.4420 1715779808000 168 2024-05-15 09:30:09-04:00 179.3200 179.3658 179.2800 179.3400 12848 179.3125 1715779809000 139 2024-05-15 09:30:10-04:00 179.3700 179.3900 179.2300 179.2700 16163 179.2792 1715779810000 141 2024-05-15 09:30:11-04:00 179.2855 179.2994 179.1900 179.2800 10562 179.2470 1715779811000 141 2024-05-15 09:30:12-04:00 179.2350 179.2980 179.2100 179.2860 6817 179.2389 1715779812000 59 2024-05-15 09:30:13-04:00 179.2500 179.3896 179.1500 179.1500 17825 179.2429 1715779813000 157 2024-05-15 09:30:14-04:00 179.1300 179.3668 179.1100 179.2140 5169 179.1685 1715779814000 97 2024-05-15 09:30:15-04:00 179.1760 179.3100 179.1400 179.2800 9648 179.2121 1715779815000 141 2024-05-15 09:30:16-04:00 179.3200 179.5200 179.2000 179.3900 19898 179.4249 1715779816000 162 2024-05-15 09:30:17-04:00 179.4200 179.4200 179.2821 179.2821 5750 179.3536 1715779817000 77 2024-05-15 09:30:18-04:00 179.2300 179.3650 179.1798 179.3650 8858 179.2348 1715779818000 77 2024-05-15 09:30:19-04:00 179.1700 179.1862 179.1100 179.1200 6437 179.1482 1715779819000 101 2024-05-15 09:30:20-04:00 179.1400 179.1900 179.1400 179.1700 6260 179.1595 1715779820000 60 2024-05-15 09:30:21-04:00 179.1700 179.1700 178.9100 178.9657 71507 179.0198 1715779821000 554 2024-05-15 09:30:22-04:00 178.9300 178.9971 178.9000 178.9400 5968 178.9575 1715779822000 103 2024-05-15 09:30:23-04:00 178.9200 178.9476 178.8300 178.8400 10347 178.9001 1715779823000 105 2024-05-15 09:30:24-04:00 178.8653 178.9300 178.8653 178.8828 8745 178.8894 1715779824000 91 2024-05-15 09:30:25-04:00 178.8700 178.9800 178.8600 178.9700 10489 178.9133 1715779825000 78 2024-05-15 09:30:26-04:00 178.9600 179.0099 178.9400 178.9400 16521 178.9637 1715779826000 69 2024-05-15 09:30:27-04:00 178.9900 179.0200 178.9783 179.0099 5752 179.0039 1715779827000 79 2024-05-15 09:30:28-04:00 178.9850 179.0000 178.9000 178.9000 11438 178.9637 1715779828000 74 2024-05-15 09:30:29-04:00 178.9200 178.9200 178.8400 178.8470 5888 178.8917 1715779829000 90 2024-05-15 09:30:30-04:00 178.8000 178.9900 178.8000 178.8400 11160 178.8769 1715779830000 193 2024-05-15 09:30:31-04:00 178.8600 178.9100 178.7700 178.9100 6323 178.8392 1715779831000 133 2024-05-15 09:30:32-04:00 178.9000 178.9386 178.7400 178.7415 8338 178.7895 1715779832000 108 2024-05-15 09:30:33-04:00 178.7200 178.8675 178.6800 178.7450 6969 178.7488 1715779833000 123 2024-05-15 09:30:34-04:00 178.7900 178.8300 178.7100 178.7100 7023 178.7759 1715779834000 71 2024-05-15 09:30:35-04:00 178.7310 178.7950 178.7310 178.7852 5325 178.7625 1715779835000 77 2024-05-15 09:30:36-04:00 178.7900 178.8399 178.7700 178.8399 3450 178.8061 1715779836000 47 2024-05-15 09:30:37-04:00 178.8100 178.8400 178.7300 178.7700 5579 178.7868 1715779837000 71 2024-05-15 09:30:38-04:00 178.7300 178.7300 178.6200 178.6900 7292 178.6814 1715779838000 110 2024-05-15 09:30:39-04:00 178.6700 178.7200 178.6200 178.6700 6240 178.6744 1715779839000 74 2024-05-15 09:30:40-04:00 178.6400 178.6401 178.4500 178.4700 16194 178.5355 1715779840000 311 2024-05-15 09:30:41-04:00 178.4999 178.6100 178.4200 178.5318 7590 178.5182 1715779841000 158 2024-05-15 09:30:42-04:00 178.5700 178.6600 178.3000 178.3001 36025 178.4809 1715779842000 588 2024-05-15 09:30:43-04:00 178.3899 178.6100 178.1200 178.1200 54431 178.3173 1715779843000 1074 2024-05-15 09:30:44-04:00 178.2100 178.4700 178.2100 178.4518 7837 178.3605 1715779844000 133 2024-05-15 09:30:45-04:00 178.4033 178.5600 178.3900 178.4708 7162 178.4761 1715779845000 121 2024-05-15 09:30:46-04:00 178.5100 178.5950 178.4800 178.4800 33570 178.5539 1715779846000 127 2024-05-15 09:30:47-04:00 178.5300 178.7000 178.4871 178.6200 10347 178.6086 1715779847000 96 2024-05-15 09:30:48-04:00 178.5400 178.7050 178.5300 178.6600 4223 178.6192 1715779848000 59 2024-05-15 09:30:49-04:00 178.7050 178.7100 178.5463 178.6300 8784 178.6763 1715779849000 52 2024-05-15 09:30:50-04:00 178.6303 178.7100 178.6200 178.6600 6935 178.6597 1715779850000 64 2024-05-15 09:30:51-04:00 178.6786 178.7200 178.5613 178.6000 8019 178.6200 1715779851000 92 2024-05-15 09:30:52-04:00 178.5617 178.7100 178.5200 178.6900 11853 178.5910 1715779852000 90 2024-05-15 09:30:53-04:00 178.6101 178.6996 178.5850 178.6400 7840 178.6431 1715779853000 58 2024-05-15 09:30:54-04:00 178.6000 178.6999 178.5620 178.6893 15361 178.6701 1715779854000 75 2024-05-15 09:30:55-04:00 178.5494 178.5700 178.4300 178.5400 4904 178.5248 1715779855000 76 2024-05-15 09:30:56-04:00 178.5700 178.6078 178.5100 178.5100 4944 178.5554 1715779856000 45 2024-05-15 09:30:57-04:00 178.5042 178.6100 178.4583 178.6089 6780 178.5191 1715779857000 71 2024-05-15 09:30:58-04:00 178.6080 178.6099 178.5400 178.5500 5220 178.5864 1715779858000 58 2024-05-15 09:30:59-04:00 178.5000 178.6100 178.5000 178.5750 7512 178.5743 1715779859000 77 2024-05-15 09:31:00-04:00 178.6100 178.6100 178.3700 178.4200 9493 178.4875 1715779860000 117 2024-05-15 09:31:01-04:00 178.4200 178.5500 178.4200 178.4795 5103 178.4798 1715779861000 59 2024-05-15 09:31:02-04:00 178.4450 178.4660 178.3800 178.4294 6942 178.4159 1715779862000 68 2024-05-15 09:31:03-04:00 178.4200 178.5000 178.4100 178.5000 3123 178.4419 1715779863000 43 2024-05-15 09:31:04-04:00 178.4600 178.5099 178.3900 178.4200 4113 178.4523 1715779864000 38 2024-05-15 09:31:05-04:00 178.3934 178.4800 178.3850 178.4501 3226 178.4319 1715779865000 34 2024-05-15 09:31:06-04:00 178.4600 178.6900 178.4600 178.6400 40831 178.5897 1715779866000 130 2024-05-15 09:31:07-04:00 178.5700 178.7499 178.5348 178.7240 14614 178.6590 1715779867000 102 2024-05-15 09:31:08-04:00 178.7499 178.7499 178.6100 178.6350 9477 178.6997 1715779868000 48 2024-05-15 09:31:09-04:00 178.6100 178.6600 178.5895 178.6400 5092 178.6252 1715779869000 79 2024-05-15 09:31:10-04:00 178.5800 178.6044 178.3500 178.4000 20868 178.4975 1715779870000 139 2024-05-15 09:31:11-04:00 178.4000 178.4700 178.3185 178.3185 4648 178.4135 1715779871000 62 2024-05-15 09:31:12-04:00 178.3100 178.3550 178.2700 178.3550 8187 178.3151 1715779872000 103 2024-05-15 09:31:13-04:00 178.3400 178.3700 178.2700 178.3622 14580 178.3325 1715779873000 113 2024-05-15 09:31:14-04:00 178.2745 178.4199 178.2745 178.4099 3880 178.3552 1715779874000 68 2024-05-15 09:31:15-04:00 178.3350 178.3582 178.2650 178.2901 10868 178.3028 1715779875000 126 2024-05-15 09:31:16-04:00 178.3100 178.3650 178.3100 178.3300 2752 178.3465 1715779876000 36 2024-05-15 09:31:17-04:00 178.3300 178.3395 178.2800 178.3200 2389 178.3031 1715779877000 39 2024-05-15 09:31:18-04:00 178.3000 178.3699 178.2700 178.3699 8420 178.2959 1715779878000 72 2024-05-15 09:31:19-04:00 178.2900 178.3200 178.2710 178.3085 4713 178.2990 1715779879000 50 2024-05-15 09:31:20-04:00 178.3309 178.3399 178.2900 178.3000 4329 178.3337 1715779880000 32 2024-05-15 09:31:21-04:00 178.2900 178.3099 178.2300 178.2450 16304 178.2679 1715779881000 162 2024-05-15 09:31:22-04:00 178.2200 178.2400 178.0700 178.0700 21050 178.1647 1715779882000 216 2024-05-15 09:31:23-04:00 178.1099 178.1300 178.0100 178.0100 10593 178.0372 1715779883000 99 2024-05-15 09:31:24-04:00 178.0800 178.1299 178.0610 178.0714 11195 178.0942 1715779884000 84 2024-05-15 09:31:25-04:00 178.0800 178.1290 178.0600 178.1290 8249 178.0888 1715779885000 37 2024-05-15 09:31:26-04:00 178.0700 178.0799 178.0000 178.0400 17760 178.0259 1715779886000 203 2024-05-15 09:31:27-04:00 178.0500 178.0800 177.9600 178.0300 56245 178.0069 1715779887000 554 2024-05-15 09:31:28-04:00 178.0300 178.0650 177.9700 178.0000 11720 178.0197 1715779888000 175 2024-05-15 09:31:29-04:00 178.0000 178.0000 177.8501 177.8600 26375 177.9674 1715779889000 263 2024-05-15 09:31:30-04:00 177.8800 177.9700 177.8100 177.8989 14057 177.8631 1715779890000 116 2024-05-15 09:31:31-04:00 177.9055 177.9600 177.8718 177.9150 9036 177.9115 1715779891000 63 2024-05-15 09:31:32-04:00 177.8900 177.8910 177.7700 177.7700 10559 177.8235 1715779892000 159 2024-05-15 09:31:33-04:00 177.7700 177.8199 177.7000 177.7399 10798 177.7596 1715779893000 103 2024-05-15 09:31:34-04:00 177.7012 177.7890 177.6600 177.7500 8002 177.7327 1715779894000 132 2024-05-15 09:31:35-04:00 177.7400 177.7899 177.6601 177.6601 12053 177.7094 1715779895000 91 2024-05-15 09:31:36-04:00 177.6764 177.7700 177.6600 177.7500 16638 177.7388 1715779896000 191 2024-05-15 09:31:37-04:00 177.7328 177.8000 177.7300 177.7300 9324 177.7504 1715779897000 93 2024-05-15 09:31:38-04:00 177.7899 177.8199 177.7400 177.7600 8103 177.7843 1715779898000 84 2024-05-15 09:31:39-04:00 177.7213 177.8400 177.7100 177.8016 9164 177.7908 1715779899000 79 2024-05-15 09:31:40-04:00 177.8050 177.9490 177.7800 177.9050 10798 177.8402 1715779900000 133 2024-05-15 09:31:41-04:00 177.8693 177.9400 177.8400 177.8900 7773 177.8789 1715779901000 76 2024-05-15 09:31:42-04:00 177.9400 177.9400 177.8700 177.8850 7095 177.9010 1715779902000 88 2024-05-15 09:31:43-04:00 177.9000 177.9450 177.7700 177.8100 10298 177.8629 1715779903000 101 2024-05-15 09:31:44-04:00 177.8000 177.8944 177.7600 177.8400 11445 177.8340 1715779904000 91 2024-05-15 09:31:45-04:00 177.8200 177.9400 177.8000 177.8757 13578 177.8555 1715779905000 93 2024-05-15 09:31:46-04:00 177.8800 178.0000 177.8800 177.9100 11544 177.9307 1715779906000 88 2024-05-15 09:31:47-04:00 177.9100 177.9100 177.8200 177.8700 5021 177.8725 1715779907000 107 2024-05-15 09:31:48-04:00 177.8400 177.8850 177.7900 177.8630 10558 177.8404 1715779908000 103 2024-05-15 09:31:49-04:00 177.8659 177.9291 177.8600 177.8900 12748 177.9034 1715779909000 64 2024-05-15 09:31:50-04:00 177.9200 177.9200 177.8400 177.8520 3536 177.8646 1715779910000 58 2024-05-15 09:31:51-04:00 177.8535 177.9400 177.8400 177.8800 11290 177.8991 1715779911000 89 2024-05-15 09:31:52-04:00 177.8700 177.9155 177.7900 177.8150 17747 177.8375 1715779912000 91 2024-05-15 09:31:53-04:00 177.8135 177.8282 177.7600 177.7900 5729 177.7971 1715779913000 74 2024-05-15 09:31:54-04:00 177.7700 177.7900 177.6800 177.6949 17240 177.7523 1715779914000 198 2024-05-15 09:31:55-04:00 177.6900 177.7900 177.6500 177.6500 8562 177.7043 1715779915000 134 2024-05-15 09:31:56-04:00 177.7000 177.7500 177.6310 177.6799 12594 177.6956 1715779916000 133 2024-05-15 09:31:57-04:00 177.6500 177.7300 177.6200 177.6500 7636 177.6623 1715779917000 185 2024-05-15 09:31:58-04:00 177.6400 177.7300 177.6400 177.7300 7757 177.6931 1715779918000 68 2024-05-15 09:31:59-04:00 177.7200 177.7700 177.6800 177.7200 10999 177.7178 1715779919000 81 2024-05-15 09:32:00-04:00 177.7700 177.7800 177.7100 177.7700 7360 177.7508 1715779920000 91 2024-05-15 09:32:01-04:00 177.7300 177.7400 177.6200 177.6300 11624 177.6749 1715779921000 86 2024-05-15 09:32:02-04:00 177.6499 177.6500 177.4800 177.4950 33634 177.5363 1715779922000 691 2024-05-15 09:32:03-04:00 177.5100 177.6300 177.4120 177.4500 16380 177.4591 1715779923000 240 2024-05-15 09:32:04-04:00 177.4350 177.4350 177.3080 177.3300 19639 177.3559 1715779924000 313 2024-05-15 09:32:05-04:00 177.3342 177.4350 177.1700 177.1728 31635 177.2524 1715779925000 246 2024-05-15 09:32:06-04:00 177.2000 177.2000 177.1300 177.1650 11237 177.1571 1715779926000 112 2024-05-15 09:32:07-04:00 177.1700 177.2100 177.1300 177.1600 16334 177.1744 1715779927000 146 2024-05-15 09:32:08-04:00 177.1800 177.2900 177.1358 177.2592 16350 177.1920 1715779928000 149 2024-05-15 09:32:09-04:00 177.2600 177.3800 177.1522 177.3000 30847 177.2956 1715779929000 224 2024-05-15 09:32:10-04:00 177.3268 177.3300 177.2100 177.2636 12107 177.2809 1715779930000 122 2024-05-15 09:32:11-04:00 177.2450 177.3150 177.0500 177.1000 22628 177.1401 1715779931000 208 2024-05-15 09:32:12-04:00 177.0900 177.2800 177.0701 177.1900 15123 177.1547 1715779932000 130 2024-05-15 09:32:13-04:00 177.1700 177.1950 177.1100 177.1950 15943 177.1514 1715779933000 141 2024-05-15 09:32:14-04:00 177.1950 177.2400 177.1300 177.1877 12740 177.1766 1715779934000 74 2024-05-15 09:32:15-04:00 177.1900 177.2250 177.0971 177.1520 13755 177.1630 1715779935000 105 2024-05-15 09:32:16-04:00 177.1300 177.2351 177.0900 177.1250 10501 177.1381 1715779936000 103 2024-05-15 09:32:17-04:00 177.1799 177.2990 177.1600 177.2300 14010 177.2064 1715779937000 95 2024-05-15 09:32:18-04:00 177.2900 177.3500 177.2201 177.3500 14798 177.2711 1715779938000 82 2024-05-15 09:32:19-04:00 177.3300 177.4300 177.3200 177.4000 12752 177.3602 1715779939000 97 2024-05-15 09:32:20-04:00 177.4000 177.4000 177.2100 177.2600 15234 177.2953 1715779940000 156 2024-05-15 09:32:21-04:00 177.2400 177.3565 177.1900 177.3565 15776 177.2419 1715779941000 152 2024-05-15 09:32:22-04:00 177.3000 177.3400 177.2309 177.2700 6011 177.2952 1715779942000 62 2024-05-15 09:32:23-04:00 177.2291 177.2700 177.0800 177.2000 15470 177.2147 1715779943000 185 2024-05-15 09:32:24-04:00 177.0950 177.1499 177.0600 177.1499 7850 177.0984 1715779944000 75 2024-05-15 09:32:25-04:00 177.1300 177.1800 177.0600 177.1400 6319 177.1249 1715779945000 106 2024-05-15 09:32:26-04:00 177.1850 177.1850 177.0751 177.0800 12189 177.1229 1715779946000 85 2024-05-15 09:32:27-04:00 177.1000 177.1600 177.1000 177.1561 5723 177.1391 1715779947000 42 2024-05-15 09:32:28-04:00 177.0900 177.1499 177.0300 177.0800 6857 177.0818 1715779948000 87 2024-05-15 09:32:29-04:00 177.0700 177.1199 177.0113 177.0500 14456 177.0604 1715779949000 132 2024-05-15 09:32:30-04:00 177.0600 177.1100 177.0201 177.1000 8864 177.0795 1715779950000 88 2024-05-15 09:32:31-04:00 177.1050 177.1700 177.0441 177.1000 7257 177.0969 1715779951000 111 2024-05-15 09:32:32-04:00 177.1150 177.1150 177.0747 177.1000 4683 177.0957 1715779952000 57 2024-05-15 09:32:33-04:00 177.0700 177.1900 177.0600 177.1100 6996 177.1060 1715779953000 110 2024-05-15 09:32:34-04:00 177.1300 177.1300 177.0500 177.1200 11739 177.0939 1715779954000 62 2024-05-15 09:32:35-04:00 177.1200 177.2200 177.1200 177.1579 10119 177.1801 1715779955000 110 2024-05-15 09:32:36-04:00 177.1600 177.2000 177.1000 177.1700 10569 177.1568 1715779956000 147 2024-05-15 09:32:37-04:00 177.1400 177.3300 177.1400 177.2500 23571 177.2313 1715779957000 131 2024-05-15 09:32:38-04:00 177.2300 177.3000 177.1816 177.2958 9104 177.2643 1715779958000 106 2024-05-15 09:32:39-04:00 177.3268 177.4700 177.3268 177.3600 12369 177.4063 1715779959000 97 2024-05-15 09:32:40-04:00 177.3914 177.4399 177.3000 177.3050 7208 177.3682 1715779960000 73 2024-05-15 09:32:41-04:00 177.3399 177.3400 177.2726 177.3100 7666 177.3060 1715779961000 82 2024-05-15 09:32:42-04:00 177.3304 177.3600 177.1600 177.2190 6550 177.2689 1715779962000 95 2024-05-15 09:32:43-04:00 177.2200 177.2599 177.1081 177.2599 8819 177.1734 1715779963000 127 2024-05-15 09:32:44-04:00 177.1800 177.2500 177.0700 177.1000 13282 177.1463 1715779964000 186 2024-05-15 09:32:45-04:00 177.0900 177.1393 177.0800 177.0900 5243 177.1098 1715779965000 78 2024-05-15 09:32:46-04:00 177.1100 177.1899 177.0500 177.0600 15715 177.0913 1715779966000 100 2024-05-15 09:32:47-04:00 177.0300 177.1099 177.0200 177.0200 4521 177.0574 1715779967000 83 2024-05-15 09:32:48-04:00 177.0500 177.0800 176.9200 176.9800 46164 176.9975 1715779968000 764 2024-05-15 09:32:49-04:00 176.9700 177.0200 176.9200 176.9400 11500 176.9770 1715779969000 215 2024-05-15 09:32:50-04:00 176.9499 177.0900 176.9300 177.0373 23761 176.9773 1715779970000 139 2024-05-15 09:32:51-04:00 177.0814 177.1000 176.9623 177.0266 9887 177.0374 1715779971000 113 2024-05-15 09:32:52-04:00 177.0540 177.0700 177.0000 177.0399 14799 177.0391 1715779972000 98 2024-05-15 09:32:53-04:00 177.0100 177.0300 176.8100 176.8100 15711 176.9145 1715779973000 209 2024-05-15 09:32:54-04:00 176.8350 177.0000 176.7500 176.8100 24164 176.8205 1715779974000 290 2024-05-15 09:32:55-04:00 176.8400 176.8800 176.7500 176.8300 22604 176.8124 1715779975000 190 2024-05-15 09:32:56-04:00 176.8200 176.8700 176.7685 176.8200 17406 176.8254 1715779976000 155 2024-05-15 09:32:57-04:00 176.8500 176.8699 176.7300 176.8099 16818 176.7848 1715779977000 151 2024-05-15 09:32:58-04:00 176.7750 176.8200 176.7000 176.7048 16359 176.7441 1715779978000 186 2024-05-15 09:32:59-04:00 176.7250 176.7800 176.6900 176.7200 15879 176.7239 1715779979000 175 2024-05-15 09:33:00-04:00 176.7300 176.7450 176.5675 176.6100 27218 176.6737 1715779980000 312 2024-05-15 09:33:01-04:00 176.6100 176.7040 176.5300 176.6100 14464 176.6038 1715779981000 205 2024-05-15 09:33:02-04:00 176.5746 176.7099 176.5739 176.6360 16541 176.6290 1715779982000 186 2024-05-15 09:33:03-04:00 176.6600 176.7000 176.5501 176.5900 12579 176.6097 1715779983000 125 2024-05-15 09:33:04-04:00 176.5900 176.6830 176.5300 176.5700 29140 176.5983 1715779984000 300 2024-05-15 09:33:05-04:00 176.6100 176.6500 176.5100 176.5900 18356 176.5648 1715779985000 236 2024-05-15 09:33:06-04:00 176.5850 176.7200 176.5200 176.6525 12551 176.6156 1715779986000 163 2024-05-15 09:33:07-04:00 176.6525 176.7200 176.6381 176.6984 11971 176.6810 1715779987000 127 2024-05-15 09:33:08-04:00 176.7200 176.9400 176.7050 176.8500 16990 176.7700 1715779988000 201
Reply
#2
Hmmmm... after doing some more research perhaps

https://docs.pola.rs/py-polars/html/refe...by_dynamic

Polars group by dynamic will do the trick instead of using pandas?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Alteryx QS-Passing pandas dataframe column inside SQL query where condition sanky1990 0 857 Dec-04-2023, 09:48 PM
Last Post: sanky1990
  A more efficient code titanif 2 600 Oct-17-2023, 02:07 PM
Last Post: deanhystad
  Question on pandas.dataframe merging two colums shomikc 4 984 Jun-29-2023, 11:30 AM
Last Post: snippsat
  Pandas AttributeError: 'DataFrame' object has no attribute 'concat' Sameer33 5 6,413 Feb-17-2023, 06:01 PM
Last Post: Sameer33
  help how to get size of pandas dataframe into MB\GB mg24 1 2,711 Jan-28-2023, 01:23 PM
Last Post: snippsat
  pandas dataframe into csv .... exponent issue mg24 10 2,123 Jan-20-2023, 08:15 PM
Last Post: deanhystad
  Making a function more efficient CatorCanulis 9 2,157 Oct-06-2022, 07:47 AM
Last Post: DPaul
  How to assign a value to pandas dataframe column rows based on a condition klllmmm 0 967 Sep-08-2022, 06:32 AM
Last Post: klllmmm
  How to retrieve records in a DataFrame (Python/Pandas) that contains leading or trail mmunozjr 3 1,966 Sep-05-2022, 11:56 AM
Last Post: Pedroski55
  "Vlookup" in pandas dataframe doug2019 3 2,091 May-09-2022, 01:35 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020