|
453 | 453 | "import ibis\n", |
454 | 454 | "\n", |
455 | 455 | "ibis.options.interactive = True\n", |
456 | | - "connection = ibis.sqlite.connect(Path(\"data/Chinook.sqlite\"))\n", |
| 456 | + "connection = ibis.sqlite.connect(\"data/Chinook.sqlite\")\n", |
457 | 457 | "track = connection.table(\"track\")\n", |
458 | 458 | "track.head()" |
459 | 459 | ] |
460 | 460 | }, |
461 | 461 | { |
462 | 462 | "cell_type": "markdown", |
463 | | - "id": "965cc983", |
| 463 | + "id": "6dcd7d71", |
464 | 464 | "metadata": {}, |
465 | 465 | "source": [ |
466 | | - "As an aside, you can list the available tables using" |
| 466 | + "Okay, now let's reproduce the following query: \"SELECT albumid, AVG(milliseconds)/1e3/60 FROM track GROUP BY albumid ORDER BY AVG(milliseconds) ASC LIMIT 5;\". We'll use a groupby, a mutate (which you can think of like **pandas**' assign statement), a sort, and then `limit()` to only show the first five entries." |
467 | 467 | ] |
468 | 468 | }, |
469 | 469 | { |
470 | 470 | "cell_type": "code", |
471 | 471 | "execution_count": null, |
472 | | - "id": "58369c80", |
| 472 | + "id": "5e5a482b", |
473 | 473 | "metadata": {}, |
474 | 474 | "outputs": [], |
475 | 475 | "source": [ |
476 | | - "connection.list_tables()" |
477 | | - ] |
478 | | - }, |
479 | | - { |
480 | | - "cell_type": "markdown", |
481 | | - "id": "6dcd7d71", |
482 | | - "metadata": {}, |
483 | | - "source": [ |
484 | | - "Okay, now let's reproduce the following query: \"SELECT albumid, AVG(milliseconds)/1e3/60 FROM track GROUP BY albumid ORDER BY AVG(milliseconds) ASC LIMIT 5;\". We'll use a groupby, a mutate (which you can think of like **pandas**' assign statement), a sort, and then `limit()` to only show the first five entries." |
| 476 | + "track.group_by(\"AlbumId\").mutate(\n", |
| 477 | + " mean_mins_track=track.Milliseconds.mean() / 1e3 / 60\n", |
| 478 | + ").order_by(\"mean_mins_track\").limit(5)" |
485 | 479 | ] |
486 | 480 | }, |
487 | 481 | { |
488 | 482 | "cell_type": "code", |
489 | 483 | "execution_count": null, |
490 | | - "id": "5e5a482b", |
| 484 | + "id": "39c80365", |
491 | 485 | "metadata": {}, |
492 | 486 | "outputs": [], |
493 | 487 | "source": [ |
494 | | - "track.group_by(\"AlbumId\").mutate(\n", |
495 | | - " mean_mins_track=track.Milliseconds.mean() / 1e3 / 60\n", |
496 | | - ").order_by(\"mean_mins_track\").limit(5)" |
| 488 | + "track.group_by(\"AlbumId\").mutate(mean_mins_track=track.Milliseconds.mean() / 1e3 / 60)" |
497 | 489 | ] |
498 | 490 | }, |
499 | 491 | { |
|
788 | 780 | "main_language": "python" |
789 | 781 | }, |
790 | 782 | "kernelspec": { |
791 | | - "display_name": "Python 3.9.12 ('python4DS')", |
| 783 | + "display_name": ".venv", |
792 | 784 | "language": "python", |
793 | 785 | "name": "python3" |
794 | 786 | }, |
|
802 | 794 | "name": "python", |
803 | 795 | "nbconvert_exporter": "python", |
804 | 796 | "pygments_lexer": "ipython3", |
805 | | - "version": "3.10.12" |
| 797 | + "version": "3.10.0" |
806 | 798 | }, |
807 | | - "toc-showtags": true, |
808 | | - "vscode": { |
809 | | - "interpreter": { |
810 | | - "hash": "9d7534ecd9fbc7d385378f8400cf4d6cb9c6175408a574f1c99c5269f08771cc" |
811 | | - } |
812 | | - } |
| 799 | + "toc-showtags": true |
813 | 800 | }, |
814 | 801 | "nbformat": 4, |
815 | 802 | "nbformat_minor": 5 |
|
0 commit comments