【ChatGPT】AIにプログラムを作らせて、FastF1 APIのデータをみる【Python】

FastF1 API

海外のメディアだけじゃなく、素人さんのブログとかでも、かなり詳しくF1のデータが見れているな~~ どっから見てるんだろう?? って。。思ってたんですよね。

特に、このインスタグラムのf1dataanalysisさん。

どっからとってきてるんだろうな?って思ったら。。Fast F1 APIっていうのがありました。

https://theoehrly.github.io/Fast-F1/

Telemetoryのデータまでとれるみたいです。Exampleもあるので、いろいろ試してみると面白いことできそう。

Austrian Grand Prix 2021 - RIC - Speed

 

 

ChatGPTに聞いてPythonで書いてもらうか?

今、話題の。。ChatGPTくん、なかなかちょっとしたPythonでのプログラムは書いてくれるので、実は便利に使っています。

で。。プログラム書かずにできるかな?と。。

JupyterLabをAnacondaから動かして。。 Code をCopyして。。

う。。 Fast F1 APIのこと知らんのか??(笑)

どうも、セッションIDやEventIDやらの仕様がよくわかっていないようで、ここのやり取りをすること。。10回以上。。

Chat-GPTって1年以上前のデータだから、最近の情報だめなんですね。。

やっぱりDoccument(笑)

Pythonで、2023年のバーレーンのレースの角田君のラップタイムを表示するプログラム

import fastf1
from fastf1 import plotting
from matplotlib import pyplot as plt

plotting.setup_mpl()

race = fastf1.get_session(2023, 'Bahrain Grand Prix', 'R')
race.load()

tsunoda = race.laps.pick_driver('TSU')
tsunoda

出力結果は。。

Time DriverNumber LapTime LapNumber PitOutTime PitInTime Sector1Time Sector2Time Sector3Time Sector1SessionTime Compound TyreLife FreshTyre Stint LapStartTime Team Driver TrackStatus IsAccurate LapStartDate
570 0 days 01:04:24.702000 22 NaT 1 0 days 00:25:04.818000 NaT NaT 0 days 00:00:45.884000 0 days 00:00:24.925000 NaT SOFT 1.0 True 1 0 days 01:02:36.652000 AlphaTauri TSU 2 False 2023-03-05 15:03:38.501
571 0 days 01:06:05.539000 22 0 days 00:01:40.837000 2 NaT NaT 0 days 00:00:31.976000 0 days 00:00:43.987000 0 days 00:00:24.874000 0 days 01:04:56.678000 SOFT 2.0 True 1 0 days 01:04:24.702000 AlphaTauri TSU 2 True 2023-03-05 15:05:26.551
572 0 days 01:07:45.782000 22 0 days 00:01:40.243000 3 NaT NaT 0 days 00:00:31.699000 0 days 00:00:43.736000 0 days 00:00:24.808000 0 days 01:06:37.238000 SOFT 3.0 True 1 0 days 01:06:05.539000 AlphaTauri TSU 1 True 2023-03-05 15:07:07.388
573 0 days 01:09:25.732000 22 0 days 00:01:39.950000 4 NaT NaT 0 days 00:00:31.259000 0 days 00:00:43.590000 0 days 00:00:25.101000 0 days 01:08:17.041000 SOFT 4.0 True 1 0 days 01:07:45.782000 AlphaTauri TSU 1 True 2023-03-05 15:08:47.631
574 0 days 01:11:06.863000 22 0 days 00:01:41.131000 5 NaT NaT 0 days 00:00:31.566000 0 days 00:00:44.562000 0 days 00:00:25.003000 0 days 01:09:57.298000 SOFT 5.0 True 1 0 days 01:09:25.732000 AlphaTauri TSU 1 True 2023-03-05 15:10:27.581
575 0 days 01:12:47.749000 22 0 days 00:01:40.886000 6 NaT NaT 0 days 00:00:31.671000 0 days 00:00:44.172000 0 days 00:00:25.043000 0 days 01:11:38.534000 SOFT 6.0 True 1 0 days 01:11:06.863000 AlphaTauri TSU 1 True 2023-03-05 15:12:08.712
576 0 days 01:14:28.701000 22 0 days 00:01:40.952000 7 NaT NaT 0 days 00:00:31.564000 0 days 00:00:44.259000 0 days 00:00:25.129000 0 days 01:13:19.313000 SOFT 7.0 True 1 0 days 01:12:47.749000 AlphaTauri TSU 1 True 2023-03-05 15:13:49.598
577 0 days 01:16:09.547000 22 0 days 00:01:40.846000 8 NaT NaT 0 days 00:00:31.566000 0 days 00:00:44.156000 0 days 00:00:25.124000 0 days 01:15:00.267000 SOFT 8.0 True 1 0 days 01:14:28.701000 AlphaTauri TSU 1 True 2023-03-05 15:15:30.550
578 0 days 01:17:50.557000 22 0 days 00:01:41.010000 9 NaT NaT 0 days 00:00:31.627000 0 days 00:00:44.241000 0 days 00:00:25.142000 0 days 01:16:41.174000 SOFT 9.0 True 1 0 days 01:16:09.547000 AlphaTauri TSU 1 True 2023-03-05 15:17:11.396
579 0 days 01:19:34.306000 22 0 days 00:01:43.749000 10 NaT 0 days 01:19:32.587000 0 days 00:00:31.649000 0 days 00:00:44.285000 0 days 00:00:27.815000 0 days 01:18:22.206000 SOFT 10.0 True 1 0 days 01:17:50.557000 AlphaTauri TSU 1 False 2023-03-05 15:18:52.406
580 0 days 01:21:34.149000 22 0 days 00:01:59.843000 11 0 days 01:19:57.836000 NaT 0 days 00:00:53.357000 0 days 00:00:42.423000 0 days 00:00:24.063000 0 days 01:20:27.663000 HARD 1.0 True 2 0 days 01:19:34.306000 AlphaTauri TSU 1 False 2023-03-05 15:20:36.155
581 0 days 01:23:13.292000 22 0 days 00:01:39.143000 12 NaT NaT 0 days 00:00:31.623000 0 days 00:00:43.140000 0 days 00:00:24.380000 0 days 01:22:05.772000 HARD 2.0 True 2 0 days 01:21:34.149000 AlphaTauri TSU 1 True 2023-03-05 15:22:35.998
582 0 days 01:24:52.763000 22 0 days 00:01:39.471000 13 NaT NaT 0 days 00:00:31.607000 0 days 00:00:43.290000 0 days 00:00:24.574000 0 days 01:23:44.899000 HARD 3.0 True 2 0 days 01:23:13.292000 AlphaTauri TSU 1 True 2023-03-05 15:24:15.141
583 0 days 01:26:31.505000 22 0 days 00:01:38.742000 14 NaT NaT 0 days 00:00:31.227000 0 days 00:00:43.111000 0 days 00:00:24.404000 0 days 01:25:23.990000 HARD 4.0 True 2 0 days 01:24:52.763000 AlphaTauri TSU 1 True 2023-03-05 15:25:54.612
584 0 days 01:28:10.480000 22 0 days 00:01:38.975000 15 NaT NaT 0 days 00:00:31.398000 0 days 00:00:43.143000 0 days 00:00:24.434000 0 days 01:27:02.903000 HARD 5.0 True 2 0 days 01:26:31.505000 AlphaTauri TSU 1 True 2023-03-05 15:27:33.354
585 0 days 01:29:49.541000 22 0 days 00:01:39.061000 16 NaT NaT 0 days 00:00:31.429000 0 days 00:00:43.184000 0 days 00:00:24.448000 0 days 01:28:41.909000 HARD 6.0 True 2 0 days 01:28:10.480000 AlphaTauri TSU 1 True 2023-03-05 15:29:12.329
586 0 days 01:31:28.562000 22 0 days 00:01:39.021000 17 NaT NaT 0 days 00:00:31.417000 0 days 00:00:43.132000 0 days 00:00:24.472000 0 days 01:30:20.958000 HARD 7.0 True 2 0 days 01:29:49.541000 AlphaTauri TSU 1 True 2023-03-05 15:30:51.390
587 0 days 01:33:07.864000 22 0 days 00:01:39.302000 18 NaT NaT 0 days 00:00:31.402000 0 days 00:00:43.402000 0 days 00:00:24.498000 0 days 01:31:59.964000 HARD 8.0 True 2 0 days 01:31:28.562000 AlphaTauri TSU 1 True 2023-03-05 15:32:30.411
588 0 days 01:34:47.034000 22 0 days 00:01:39.170000 19 NaT NaT 0 days 00:00:31.456000 0 days 00:00:43.331000 0 days 00:00:24.383000 0 days 01:33:39.320000 HARD 9.0 True 2 0 days 01:33:07.864000 AlphaTauri TSU 1 True 2023-03-05 15:34:09.713
589 0 days 01:36:26.316000 22 0 days 00:01:39.282000 20 NaT NaT 0 days 00:00:31.476000 0 days 00:00:43.398000 0 days 00:00:24.408000 0 days 01:35:18.510000 HARD 10.0 True 2 0 days 01:34:47.034000 AlphaTauri TSU 1 True 2023-03-05 15:35:48.883
590 0 days 01:38:05.641000 22 0 days 00:01:39.325000 21 NaT NaT 0 days 00:00:31.486000 0 days 00:00:43.285000 0 days 00:00:24.554000 0 days 01:36:57.802000 HARD 11.0 True 2 0 days 01:36:26.316000 AlphaTauri TSU 1 True 2023-03-05 15:37:28.165
591 0 days 01:39:45.080000 22 0 days 00:01:39.439000 22 NaT NaT 0 days 00:00:31.479000 0 days 00:00:43.415000 0 days 00:00:24.545000 0 days 01:38:37.120000 HARD 12.0 True 2 0 days 01:38:05.641000 AlphaTauri TSU 1 True 2023-03-05 15:39:07.490
592 0 days 01:41:24.712000 22 0 days 00:01:39.632000 23 NaT NaT 0 days 00:00:31.543000 0 days 00:00:43.474000 0 days 00:00:24.615000 0 days 01:40:16.623000 HARD 13.0 True 2 0 days 01:39:45.080000 AlphaTauri TSU 1 True 2023-03-05 15:40:46.929
593 0 days 01:43:04.821000 22 0 days 00:01:40.109000 24 NaT NaT 0 days 00:00:32.039000 0 days 00:00:43.405000 0 days 00:00:24.665000 0 days 01:41:56.751000 HARD 14.0 True 2 0 days 01:41:24.712000 AlphaTauri TSU 1 True 2023-03-05 15:42:26.561
594 0 days 01:44:44.567000 22 0 days 00:01:39.746000 25 NaT NaT 0 days 00:00:31.638000 0 days 00:00:43.565000 0 days 00:00:24.543000 0 days 01:43:36.459000 HARD 15.0 True 2 0 days 01:43:04.821000 AlphaTauri TSU 1 True 2023-03-05 15:44:06.670
595 0 days 01:46:26.794000 22 0 days 00:01:42.227000 26 NaT 0 days 01:46:25.026000 0 days 00:00:31.619000 0 days 00:00:43.452000 0 days 00:00:27.156000 0 days 01:45:16.186000 HARD 16.0 True 2 0 days 01:44:44.567000 AlphaTauri TSU 1 False 2023-03-05 15:45:46.416
596 0 days 01:48:27.094000 22 0 days 00:02:00.300000 27 0 days 01:46:49.416000 NaT 0 days 00:00:52.788000 0 days 00:00:43.364000 0 days 00:00:24.148000 0 days 01:47:19.582000 HARD 1.0 True 3 0 days 01:46:26.794000 AlphaTauri TSU 1 False 2023-03-05 15:47:28.643
597 0 days 01:50:04.918000 22 0 days 00:01:37.824000 28 NaT NaT 0 days 00:00:31.040000 0 days 00:00:42.788000 0 days 00:00:23.996000 0 days 01:48:58.134000 HARD 2.0 True 3 0 days 01:48:27.094000 AlphaTauri TSU 1 True 2023-03-05 15:49:28.943
598 0 days 01:51:42.697000 22 0 days 00:01:37.779000 29 NaT NaT 0 days 00:00:31.071000 0 days 00:00:42.582000 0 days 00:00:24.126000 0 days 01:50:35.989000 HARD 3.0 True 3 0 days 01:50:04.918000 AlphaTauri TSU 1 True 2023-03-05 15:51:06.767
599 0 days 01:53:20.844000 22 0 days 00:01:38.147000 30 NaT NaT 0 days 00:00:31.111000 0 days 00:00:42.762000 0 days 00:00:24.274000 0 days 01:52:13.808000 HARD 4.0 True 3 0 days 01:51:42.697000 AlphaTauri TSU 1 True 2023-03-05 15:52:44.546
600 0 days 01:54:58.657000 22 0 days 00:01:37.813000 31 NaT NaT 0 days 00:00:30.795000 0 days 00:00:42.857000 0 days 00:00:24.161000 0 days 01:53:51.639000 HARD 5.0 True 3 0 days 01:53:20.844000 AlphaTauri TSU 1 True 2023-03-05 15:54:22.693
601 0 days 01:56:36.674000 22 0 days 00:01:38.017000 32 NaT NaT 0 days 00:00:30.916000 0 days 00:00:42.886000 0 days 00:00:24.215000 0 days 01:55:29.573000 HARD 6.0 True 3 0 days 01:54:58.657000 AlphaTauri TSU 1 True 2023-03-05 15:56:00.506
602 0 days 01:58:14.768000 22 0 days 00:01:38.094000 33 NaT NaT 0 days 00:00:30.843000 0 days 00:00:42.923000 0 days 00:00:24.328000 0 days 01:57:07.517000 HARD 7.0 True 3 0 days 01:56:36.674000 AlphaTauri TSU 1 True 2023-03-05 15:57:38.523
603 0 days 01:59:52.898000 22 0 days 00:01:38.130000 34 NaT NaT 0 days 00:00:30.924000 0 days 00:00:42.881000 0 days 00:00:24.325000 0 days 01:58:45.692000 HARD 8.0 True 3 0 days 01:58:14.768000 AlphaTauri TSU 1 True 2023-03-05 15:59:16.617
604 0 days 02:01:31.061000 22 0 days 00:01:38.163000 35 NaT NaT 0 days 00:00:31.053000 0 days 00:00:42.779000 0 days 00:00:24.331000 0 days 02:00:23.951000 HARD 9.0 True 3 0 days 01:59:52.898000 AlphaTauri TSU 1 True 2023-03-05 16:00:54.747
605 0 days 02:03:09.120000 22 0 days 00:01:38.059000 36 NaT NaT 0 days 00:00:30.891000 0 days 00:00:42.924000 0 days 00:00:24.244000 0 days 02:02:01.952000 HARD 10.0 True 3 0 days 02:01:31.061000 AlphaTauri TSU 1 True 2023-03-05 16:02:32.910
606 0 days 02:04:47.195000 22 0 days 00:01:38.075000 37 NaT NaT 0 days 00:00:31.004000 0 days 00:00:42.708000 0 days 00:00:24.363000 0 days 02:03:40.124000 HARD 11.0 True 3 0 days 02:03:09.120000 AlphaTauri TSU 1 True 2023-03-05 16:04:10.969
607 0 days 02:06:25.279000 22 0 days 00:01:38.084000 38 NaT NaT 0 days 00:00:30.904000 0 days 00:00:42.811000 0 days 00:00:24.369000 0 days 02:05:18.099000 HARD 12.0 True 3 0 days 02:04:47.195000 AlphaTauri TSU 1 True 2023-03-05 16:05:49.044
608 0 days 02:08:03.698000 22 0 days 00:01:38.419000 39 NaT NaT 0 days 00:00:31.108000 0 days 00:00:42.882000 0 days 00:00:24.429000 0 days 02:06:56.387000 HARD 13.0 True 3 0 days 02:06:25.279000 AlphaTauri TSU 1 True 2023-03-05 16:07:27.128
609 0 days 02:09:54.048000 22 0 days 00:01:50.350000 40 NaT 0 days 02:09:52.391000 0 days 00:00:31.083000 0 days 00:00:42.908000 0 days 00:00:36.359000 0 days 02:08:34.781000 HARD 14.0 True 3 0 days 02:08:03.698000 AlphaTauri TSU 26 False 2023-03-05 16:09:05.547
610 0 days 02:12:04.830000 22 0 days 00:02:10.782000 41 0 days 02:10:18.125000 NaT 0 days 00:01:03.303000 0 days 00:00:43.564000 0 days 00:00:23.915000 0 days 02:10:57.351000 SOFT 4.0 False 4 0 days 02:09:54.048000 AlphaTauri TSU 67 False 2023-03-05 16:10:55.897
611 0 days 02:13:41.467000 22 0 days 00:01:36.637000 42 NaT NaT 0 days 00:00:30.997000 0 days 00:00:41.735000 0 days 00:00:23.905000 0 days 02:12:35.827000 SOFT 5.0 False 4 0 days 02:12:04.830000 AlphaTauri TSU 1 True 2023-03-05 16:13:06.679
612 0 days 02:15:18.495000 22 0 days 00:01:37.028000 43 NaT NaT 0 days 00:00:31.115000 0 days 00:00:42.080000 0 days 00:00:23.833000 0 days 02:14:12.582000 SOFT 6.0 False 4 0 days 02:13:41.467000 AlphaTauri TSU 1 True 2023-03-05 16:14:43.316
613 0 days 02:16:55.505000 22 0 days 00:01:37.010000 44 NaT NaT 0 days 00:00:30.939000 0 days 00:00:42.198000 0 days 00:00:23.873000 0 days 02:15:49.434000 SOFT 7.0 False 4 0 days 02:15:18.495000 AlphaTauri TSU 1 True 2023-03-05 16:16:20.344
614 0 days 02:18:32.526000 22 0 days 00:01:37.021000 45 NaT NaT 0 days 00:00:30.930000 0 days 00:00:42.107000 0 days 00:00:23.984000 0 days 02:17:26.435000 SOFT 8.0 False 4 0 days 02:16:55.505000 AlphaTauri TSU 1 True 2023-03-05 16:17:57.354
615 0 days 02:20:09.784000 22 0 days 00:01:37.258000 46 NaT NaT 0 days 00:00:31.009000 0 days 00:00:42.280000 0 days 00:00:23.969000 0 days 02:19:03.535000 SOFT 9.0 False 4 0 days 02:18:32.526000 AlphaTauri TSU 1 True 2023-03-05 16:19:34.375
616 0 days 02:21:47.143000 22 0 days 00:01:37.359000 47 NaT NaT 0 days 00:00:31.083000 0 days 00:00:42.286000 0 days 00:00:23.990000 0 days 02:20:40.867000 SOFT 10.0 False 4 0 days 02:20:09.784000 AlphaTauri TSU 1 True 2023-03-05 16:21:11.633
617 0 days 02:23:24.381000 22 0 days 00:01:37.238000 48 NaT NaT 0 days 00:00:30.963000 0 days 00:00:42.173000 0 days 00:00:24.102000 0 days 02:22:18.106000 SOFT 11.0 False 4 0 days 02:21:47.143000 AlphaTauri TSU 1 True 2023-03-05 16:22:48.992
618 0 days 02:25:01.909000 22 0 days 00:01:37.528000 49 NaT NaT 0 days 00:00:31.034000 0 days 00:00:42.419000 0 days 00:00:24.075000 0 days 02:23:55.415000 SOFT 12.0 False 4 0 days 02:23:24.381000 AlphaTauri TSU 1 True 2023-03-05 16:24:26.230
619 0 days 02:26:39.533000 22 0 days 00:01:37.624000 50 NaT NaT 0 days 00:00:31.076000 0 days 00:00:42.378000 0 days 00:00:24.170000 0 days 02:25:32.985000 SOFT 13.0 False 4 0 days 02:25:01.909000 AlphaTauri TSU 1 True 2023-03-05 16:26:03.758
620 0 days 02:28:17.239000 22 0 days 00:01:37.706000 51 NaT NaT 0 days 00:00:31.074000 0 days 00:00:42.499000 0 days 00:00:24.133000 0 days 02:27:10.607000 SOFT 14.0 False 4 0 days 02:26:39.533000 AlphaTauri TSU 1 True 2023-03-05 16:27:41.382
621 0 days 02:29:54.829000 22 0 days 00:01:37.590000 52 NaT NaT 0 days 00:00:31.005000 0 days 00:00:42.419000 0 days 00:00:24.166000 0 days 02:28:48.244000 SOFT 15.0 False 4 0 days 02:28:17.239000 AlphaTauri TSU 1 True 2023-03-05 16:29:19.088
622 0 days 02:31:32.504000 22 0 days 00:01:37.675000 53 NaT NaT 0 days 00:00:30.863000 0 days 00:00:42.461000 0 days 00:00:24.351000 0 days 02:30:25.692000 SOFT 16.0 False 4 0 days 02:29:54.829000 AlphaTauri TSU 1 True 2023-03-05 16:30:56.678
623 0 days 02:33:10.224000 22 0 days 00:01:37.720000 54 NaT NaT 0 days 00:00:31.051000 0 days 00:00:42.411000 0 days 00:00:24.258000 0 days 02:32:03.555000 SOFT 17.0 False 4 0 days 02:31:32.504000 AlphaTauri TSU 1 True 2023-03-05 16:32:34.353
624 0 days 02:34:48.169000 22 0 days 00:01:37.945000 55 NaT NaT 0 days 00:00:30.804000 0 days 00:00:42.709000 0 days 00:00:24.432000 0 days 02:33:41.028000 SOFT 18.0 False 4 0 days 02:33:10.224000 AlphaTauri TSU 1 True 2023-03-05 16:34:12.073
625 0 days 02:36:26.271000 22 0 days 00:01:38.102000 56 NaT NaT 0 days 00:00:30.921000 0 days 00:00:42.841000 0 days 00:00:24.340000 0 days 02:35:19.090000 SOFT 19.0 False 4 0 days 02:34:48.169000 AlphaTauri TSU 1 True 2023-03-05 16:35:50.018
626 0 days 02:38:04.517000 22 0 days 00:01:38.246000 57 NaT NaT 0 days 00:00:30.946000 0 days 00:00:42.795000 0 days 00:00:24.505000 0 days 02:36:57.217000 SOFT 20.0 False 4 0 days 02:36:26.271000 AlphaTauri TSU 1 True 2023-03-05 16:37:28.120

57 rows × 27 columns

グラフで表示しないとわからないよね。。

fig, ax = plt.subplots()
ax.plot(tsunoda['LapNumber'], tsunoda['LapTime'], color='red')
ax.set_title("Tsunoda Bahrain")
ax.set_xlabel("Lap Number")
ax.set_ylabel("Lap Time")
plt.show()

って打つと

 

でた(笑)

教訓 ChatGPTは、最新情報でない(笑)

でも、結構使えるのよね。。matplotとかいろいろ忘れるじゃないですか。。そういうの便利です(笑)

FastF1はなんかいろいろかなり頻繁に変わっていってるのかな?(笑)

知識のない人にいくらきいても、正しい答えは出てこない。ちゃんと出典元にあたりましょう!

っていう本当に常識的なことが今回の教訓です(笑)

 

Bingはどう??

スマホバージョンだと、ちゃんと答えますね。。

でもこちらのコードもちょっと古いですね。。

import fastf1 as ff1
from fastf1 import plotting
import matplotlib.pyplot as plt

# Load data for Bahrain GP 2023
session = ff1.get_session(2023, 'Bahrain', 'R')

# Load data for Yuki Tsunoda
laps = session.load_laps(with_telemetry=True)
tsunoda = laps.pick_driver('Tsunoda')

# Plot lap times for Yuki Tsunoda
plotting.setup_mpl()
plt.plot(tsunoda['LapNumber'], tsunoda['LapTime'])
plt.xlabel('Lap Number')
plt.ylabel('Lap Time (s)')
plt.title('Yuki Tsunoda Lap Times - Bahrain GP 2023')
plt.show()

 

ーーーーーーーーー

追加

こんなことしなくても。。F1のテレメトリデータ見るのにいいサイトあるんですね。

https://www.f1-tempo.com/

 

投稿者 tom2rd

コメントを残していただけるとありがたいです

Loading Facebook Comments ...

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください