|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "markdown",
|
5 |
| - "id": "68dc5021", |
| 5 | + "id": "1d7f096b", |
6 | 6 | "metadata": {},
|
7 | 7 | "source": [
|
8 | 8 | "# pandas-render\n",
|
|
26 | 26 | {
|
27 | 27 | "cell_type": "code",
|
28 | 28 | "execution_count": 1,
|
29 |
| - "id": "6ea43e77", |
| 29 | + "id": "19754f59", |
30 | 30 | "metadata": {
|
31 | 31 | "execution": {
|
32 |
| - "iopub.execute_input": "2025-04-07T00:28:52.409362Z", |
33 |
| - "iopub.status.busy": "2025-04-07T00:28:52.408839Z", |
34 |
| - "iopub.status.idle": "2025-04-07T00:28:52.592818Z", |
35 |
| - "shell.execute_reply": "2025-04-07T00:28:52.592444Z" |
| 32 | + "iopub.execute_input": "2025-04-07T17:30:47.432559Z", |
| 33 | + "iopub.status.busy": "2025-04-07T17:30:47.432243Z", |
| 34 | + "iopub.status.idle": "2025-04-07T17:30:47.637396Z", |
| 35 | + "shell.execute_reply": "2025-04-07T17:30:47.637034Z" |
36 | 36 | }
|
37 | 37 | },
|
38 | 38 | "outputs": [],
|
|
42 | 42 | },
|
43 | 43 | {
|
44 | 44 | "cell_type": "markdown",
|
45 |
| - "id": "bee15df6", |
| 45 | + "id": "9426c10f", |
46 | 46 | "metadata": {},
|
47 | 47 | "source": [
|
48 | 48 | "Or import it implicitly after importing pandas:\n",
|
|
55 | 55 | },
|
56 | 56 | {
|
57 | 57 | "cell_type": "markdown",
|
58 |
| - "id": "58169ddd", |
| 58 | + "id": "9b629166", |
59 | 59 | "metadata": {},
|
60 | 60 | "source": [
|
61 | 61 | "### Data\n",
|
|
65 | 65 | {
|
66 | 66 | "cell_type": "code",
|
67 | 67 | "execution_count": 2,
|
68 |
| - "id": "7daa0abe", |
| 68 | + "id": "14ea1b91", |
69 | 69 | "metadata": {
|
70 | 70 | "execution": {
|
71 |
| - "iopub.execute_input": "2025-04-07T00:28:52.594680Z", |
72 |
| - "iopub.status.busy": "2025-04-07T00:28:52.594539Z", |
73 |
| - "iopub.status.idle": "2025-04-07T00:28:52.597500Z", |
74 |
| - "shell.execute_reply": "2025-04-07T00:28:52.597234Z" |
| 71 | + "iopub.execute_input": "2025-04-07T17:30:47.639175Z", |
| 72 | + "iopub.status.busy": "2025-04-07T17:30:47.639024Z", |
| 73 | + "iopub.status.idle": "2025-04-07T17:30:47.642981Z", |
| 74 | + "shell.execute_reply": "2025-04-07T17:30:47.642640Z" |
75 | 75 | }
|
76 | 76 | },
|
77 | 77 | "outputs": [],
|
|
108 | 108 | },
|
109 | 109 | {
|
110 | 110 | "cell_type": "markdown",
|
111 |
| - "id": "b37e95b2", |
| 111 | + "id": "ec553af5", |
112 | 112 | "metadata": {},
|
113 | 113 | "source": [
|
114 | 114 | "Here is the original rendering of the DataFrame. It's a simple table with no formatting or styling. It's not very readable, and the data is not very visually appealing."
|
|
117 | 117 | {
|
118 | 118 | "cell_type": "code",
|
119 | 119 | "execution_count": 3,
|
120 |
| - "id": "1f2f75bd", |
| 120 | + "id": "d638b411", |
121 | 121 | "metadata": {
|
122 | 122 | "execution": {
|
123 |
| - "iopub.execute_input": "2025-04-07T00:28:52.598862Z", |
124 |
| - "iopub.status.busy": "2025-04-07T00:28:52.598747Z", |
125 |
| - "iopub.status.idle": "2025-04-07T00:28:52.605018Z", |
126 |
| - "shell.execute_reply": "2025-04-07T00:28:52.604748Z" |
| 123 | + "iopub.execute_input": "2025-04-07T17:30:47.644468Z", |
| 124 | + "iopub.status.busy": "2025-04-07T17:30:47.644275Z", |
| 125 | + "iopub.status.idle": "2025-04-07T17:30:47.652089Z", |
| 126 | + "shell.execute_reply": "2025-04-07T17:30:47.651611Z" |
127 | 127 | }
|
128 | 128 | },
|
129 | 129 | "outputs": [
|
|
216 | 216 | },
|
217 | 217 | {
|
218 | 218 | "cell_type": "markdown",
|
219 |
| - "id": "f675bb5c", |
| 219 | + "id": "b9d4a17d", |
220 | 220 | "metadata": {},
|
221 | 221 | "source": [
|
222 | 222 | "### Rendering\n",
|
|
226 | 226 | {
|
227 | 227 | "cell_type": "code",
|
228 | 228 | "execution_count": 4,
|
229 |
| - "id": "7294211c", |
| 229 | + "id": "da1276d0", |
230 | 230 | "metadata": {
|
231 | 231 | "execution": {
|
232 |
| - "iopub.execute_input": "2025-04-07T00:28:52.606415Z", |
233 |
| - "iopub.status.busy": "2025-04-07T00:28:52.606326Z", |
234 |
| - "iopub.status.idle": "2025-04-07T00:28:52.612477Z", |
235 |
| - "shell.execute_reply": "2025-04-07T00:28:52.612154Z" |
| 232 | + "iopub.execute_input": "2025-04-07T17:30:47.654152Z", |
| 233 | + "iopub.status.busy": "2025-04-07T17:30:47.654024Z", |
| 234 | + "iopub.status.idle": "2025-04-07T17:30:47.662245Z", |
| 235 | + "shell.execute_reply": "2025-04-07T17:30:47.661961Z" |
236 | 236 | }
|
237 | 237 | },
|
238 | 238 | "outputs": [
|
|
267 | 267 | },
|
268 | 268 | {
|
269 | 269 | "cell_type": "markdown",
|
270 |
| - "id": "fc3abf15", |
| 270 | + "id": "4cd2cc89", |
271 | 271 | "metadata": {},
|
272 | 272 | "source": [
|
273 | 273 | "### Filtering and Ordering\n",
|
|
277 | 277 | {
|
278 | 278 | "cell_type": "code",
|
279 | 279 | "execution_count": 5,
|
280 |
| - "id": "e7140340", |
| 280 | + "id": "c9378ef0", |
281 | 281 | "metadata": {
|
282 | 282 | "execution": {
|
283 |
| - "iopub.execute_input": "2025-04-07T00:28:52.614022Z", |
284 |
| - "iopub.status.busy": "2025-04-07T00:28:52.613928Z", |
285 |
| - "iopub.status.idle": "2025-04-07T00:28:52.617942Z", |
286 |
| - "shell.execute_reply": "2025-04-07T00:28:52.617661Z" |
| 283 | + "iopub.execute_input": "2025-04-07T17:30:47.663706Z", |
| 284 | + "iopub.status.busy": "2025-04-07T17:30:47.663611Z", |
| 285 | + "iopub.status.idle": "2025-04-07T17:30:47.668254Z", |
| 286 | + "shell.execute_reply": "2025-04-07T17:30:47.667971Z" |
287 | 287 | },
|
288 | 288 | "lines_to_next_cell": 2
|
289 | 289 | },
|
|
317 | 317 | },
|
318 | 318 | {
|
319 | 319 | "cell_type": "markdown",
|
320 |
| - "id": "8aa1adef", |
| 320 | + "id": "cb0eb6f5", |
321 | 321 | "metadata": {},
|
322 | 322 | "source": [
|
323 | 323 | "### Dynamic Placeholder\n",
|
|
328 | 328 | {
|
329 | 329 | "cell_type": "code",
|
330 | 330 | "execution_count": 6,
|
331 |
| - "id": "b109afa6", |
| 331 | + "id": "de08bd58", |
332 | 332 | "metadata": {
|
333 | 333 | "execution": {
|
334 |
| - "iopub.execute_input": "2025-04-07T00:28:52.619231Z", |
335 |
| - "iopub.status.busy": "2025-04-07T00:28:52.619147Z", |
336 |
| - "iopub.status.idle": "2025-04-07T00:28:52.624303Z", |
337 |
| - "shell.execute_reply": "2025-04-07T00:28:52.624019Z" |
| 334 | + "iopub.execute_input": "2025-04-07T17:30:47.669544Z", |
| 335 | + "iopub.status.busy": "2025-04-07T17:30:47.669450Z", |
| 336 | + "iopub.status.idle": "2025-04-07T17:30:47.675089Z", |
| 337 | + "shell.execute_reply": "2025-04-07T17:30:47.674763Z" |
338 | 338 | }
|
339 | 339 | },
|
340 | 340 | "outputs": [
|
|
412 | 412 | " custom_columns_names=[\"Image\", \"Title\", \"Actors\"],\n",
|
413 | 413 | ")"
|
414 | 414 | ]
|
| 415 | + }, |
| 416 | + { |
| 417 | + "cell_type": "markdown", |
| 418 | + "id": "00e5f72a", |
| 419 | + "metadata": {}, |
| 420 | + "source": [ |
| 421 | + "### Gallery\n", |
| 422 | + "If you have just one column to render, you can use the parameter `n` to specify the number of cells to render in each row side by side. This is useful for creating an overview of images or other content. The table head will be hidden automatically." |
| 423 | + ] |
| 424 | + }, |
| 425 | + { |
| 426 | + "cell_type": "code", |
| 427 | + "execution_count": 7, |
| 428 | + "id": "1cef151d", |
| 429 | + "metadata": { |
| 430 | + "execution": { |
| 431 | + "iopub.execute_input": "2025-04-07T17:30:47.676327Z", |
| 432 | + "iopub.status.busy": "2025-04-07T17:30:47.676238Z", |
| 433 | + "iopub.status.idle": "2025-04-07T17:30:47.680299Z", |
| 434 | + "shell.execute_reply": "2025-04-07T17:30:47.680024Z" |
| 435 | + } |
| 436 | + }, |
| 437 | + "outputs": [ |
| 438 | + { |
| 439 | + "data": { |
| 440 | + "text/html": [ |
| 441 | + "<table><tr><td>\n", |
| 442 | + " <div style=\"text-align: center;\">\n", |
| 443 | + " <img src=\"https://m.media-amazon.com/images/M/MV5BZDI5YzJhODQtMzQyNy00YWNmLWIxMjUtNDBjNjA5YWRjMzExXkEyXkFqcGc@._V1_QL75_UX380_CR0,4,380,562_.jpg\" width=\"100\"/>\n", |
| 444 | + " <p><a href=\"https://www.imdb.com/title/tt11280740\" target=\"_blank\">SEVERANCE</a></p>\n", |
| 445 | + " <p><smaller><strong>8.7 ★</strong></smaller></p>\n", |
| 446 | + " </div>\n", |
| 447 | + " </td><td>\n", |
| 448 | + " <div style=\"text-align: center;\">\n", |
| 449 | + " <img src=\"https://m.media-amazon.com/images/M/MV5BMjg2NmM0MTEtYWY2Yy00NmFlLTllNTMtMjVkZjEwMGVlNzdjXkEyXkFqcGc@._V1_QL75_UX380_CR0,0,380,562_.jpg\" width=\"100\"/>\n", |
| 450 | + " <p><a href=\"https://www.imdb.com/title/tt4574334\" target=\"_blank\">STRANGER THINGS</a></p>\n", |
| 451 | + " <p><smaller><strong>8.6 ★</strong></smaller></p>\n", |
| 452 | + " </div>\n", |
| 453 | + " </td></tr><tr><td>\n", |
| 454 | + " <div style=\"text-align: center;\">\n", |
| 455 | + " <img src=\"https://m.media-amazon.com/images/M/MV5BZWUwNjExYTYtZmM3ZS00NzA1LWJhNjYtMWExNGEwZTVjNDM3XkEyXkFqcGc@._V1_QL75_UY562_CR8,0,380,562_.jpg\" width=\"100\"/>\n", |
| 456 | + " <p><a href=\"https://www.imdb.com/title/tt0209264\" target=\"_blank\">PYTHON</a></p>\n", |
| 457 | + " <p><smaller><strong>3.7 ★</strong></smaller></p>\n", |
| 458 | + " </div>\n", |
| 459 | + " </td></tr></table>" |
| 460 | + ], |
| 461 | + "text/plain": [ |
| 462 | + "<IPython.core.display.HTML object>" |
| 463 | + ] |
| 464 | + }, |
| 465 | + "execution_count": 7, |
| 466 | + "metadata": {}, |
| 467 | + "output_type": "execute_result" |
| 468 | + } |
| 469 | + ], |
| 470 | + "source": [ |
| 471 | + "df.render(\n", |
| 472 | + " templates=dict(\n", |
| 473 | + " image_url=\"\"\"\n", |
| 474 | + " <div style=\"text-align: center;\">\n", |
| 475 | + " <img src=\"{{ content }}\" width=\"100\"/>\n", |
| 476 | + " <p><a href=\"https://www.imdb.com/title/{{ id }}\" target=\"_blank\">{{ title|upper }}</a></p>\n", |
| 477 | + " <p><smaller><strong>{{ rating }} ★</strong></smaller></p>\n", |
| 478 | + " </div>\n", |
| 479 | + " \"\"\",\n", |
| 480 | + " ),\n", |
| 481 | + " filter_columns=True,\n", |
| 482 | + " n=2,\n", |
| 483 | + ")" |
| 484 | + ] |
415 | 485 | }
|
416 | 486 | ],
|
417 | 487 | "metadata": {
|
|
0 commit comments