A monorepo containing jupyter-blocks and jupyter-tidyblocks. Blockly extension for JupyterLab.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add new datasets

+49
+3
docs/blocks-reference.md
··· 18 18 | Block label | Block type | dplyr equivalent | What it does | Python generated | 19 19 |---|---|---|---|---| 20 20 | penguins dataset | `tidyblocks_data_penguins` | — | Palmer Penguins dataset loaded via seaborn | `_df = sns.load_dataset('penguins')` | 21 + | iris dataset | `tidyblocks_data_iris` | — | Fisher iris dataset: sepal/petal measurements for 3 species (via seaborn) | `_df = sns.load_dataset('iris')` | 22 + | titanic dataset | `tidyblocks_data_titanic` | — | Titanic passenger survival dataset (via seaborn) | `_df = sns.load_dataset('titanic')` | 23 + | gapminder dataset | `tidyblocks_data_gapminder` | — | Gapminder life expectancy / GDP dataset across countries and years (via plotly.express) | `_df = px.data.gapminder()` | 21 24 | colors dataset | `tidyblocks_data_colors` | — | Built-in table of 11 colors with RGB values | `_df = pd.DataFrame({...})` | 22 25 | earthquakes dataset | `tidyblocks_data_earthquakes` | — | 2016 global earthquake data from gvwilson/tidyblocks | `_df = pd.read_csv('<url>')` | 23 26 | sequence 1 to N as col | `tidyblocks_data_sequence` | — | Integer sequence 1..N in a named column | `_df = pd.DataFrame({'col': range(1, N+1)})` |
+31
packages/tidyblocks/src/blocks/data.ts
··· 15 15 import seaborn as sns 16 16 `; 17 17 18 + // gapminder comes from plotly.express; needs its own preamble so that 19 + // px.data is available even when no plot block is on the canvas. 20 + const TOPLEVEL_INIT_PX = `import pandas as pd 21 + import numpy as np 22 + import plotly.express as px 23 + `; 24 + 18 25 Blockly.defineBlocksWithJsonArray([ 19 26 { 20 27 type: 'tidyblocks_data_colors', ··· 57 64 tooltip: 'Reference a previously saved DataFrame by variable name.' 58 65 }, 59 66 { 67 + type: 'tidyblocks_data_iris', 68 + message0: 'iris dataset', 69 + nextStatement: null, 70 + colour: '#FEBE4C', 71 + tooltip: 'Classic Fisher iris dataset: sepal/petal measurements for 3 species (via seaborn).' 72 + }, 73 + { 74 + type: 'tidyblocks_data_titanic', 75 + message0: 'titanic dataset', 76 + nextStatement: null, 77 + colour: '#FEBE4C', 78 + tooltip: 'Titanic passenger survival dataset (via seaborn).' 79 + }, 80 + { 81 + type: 'tidyblocks_data_gapminder', 82 + message0: 'gapminder dataset', 83 + nextStatement: null, 84 + colour: '#FEBE4C', 85 + tooltip: 'Gapminder life expectancy / GDP dataset across countries and years (via plotly.express).' 86 + }, 87 + { 60 88 type: 'tidyblocks_data_csv', 61 89 message0: 'read CSV %1', 62 90 args0: [{ type: 'field_input', name: 'PATH', text: 'data.csv' }], ··· 73 101 Blockly.Blocks['tidyblocks_data_penguins'].toplevel_init = TOPLEVEL_INIT; 74 102 Blockly.Blocks['tidyblocks_data_sequence'].toplevel_init = TOPLEVEL_INIT; 75 103 Blockly.Blocks['tidyblocks_data_user'].toplevel_init = TOPLEVEL_INIT; 104 + Blockly.Blocks['tidyblocks_data_iris'].toplevel_init = TOPLEVEL_INIT; 105 + Blockly.Blocks['tidyblocks_data_titanic'].toplevel_init = TOPLEVEL_INIT; 106 + Blockly.Blocks['tidyblocks_data_gapminder'].toplevel_init = TOPLEVEL_INIT_PX; 76 107 Blockly.Blocks['tidyblocks_data_csv'].toplevel_init = TOPLEVEL_INIT;
+12
packages/tidyblocks/src/generators/python/data.ts
··· 32 32 return `_df = ${name}.copy()\n`; 33 33 }; 34 34 35 + pythonGenerator.forBlock['tidyblocks_data_iris'] = () => { 36 + return "_df = sns.load_dataset('iris')\n"; 37 + }; 38 + 39 + pythonGenerator.forBlock['tidyblocks_data_titanic'] = () => { 40 + return "_df = sns.load_dataset('titanic')\n"; 41 + }; 42 + 43 + pythonGenerator.forBlock['tidyblocks_data_gapminder'] = () => { 44 + return "_df = px.data.gapminder()\n"; 45 + }; 46 + 35 47 pythonGenerator.forBlock['tidyblocks_data_csv'] = block => { 36 48 const path = block.getFieldValue('PATH'); 37 49 return `_df = pd.read_csv('${path}')\n`;
+3
packages/tidyblocks/src/toolbox.ts
··· 14 14 colour: '#FEBE4C', 15 15 contents: [ 16 16 { kind: 'block', type: 'tidyblocks_data_penguins' }, 17 + { kind: 'block', type: 'tidyblocks_data_iris' }, 18 + { kind: 'block', type: 'tidyblocks_data_titanic' }, 19 + { kind: 'block', type: 'tidyblocks_data_gapminder' }, 17 20 { kind: 'block', type: 'tidyblocks_data_colors' }, 18 21 { kind: 'block', type: 'tidyblocks_data_earthquakes' }, 19 22 {