paddymul / buckaroo

Buckaroo - the data wrangling assistant for pandas. Quickly explore dataframes, and run pandas commands via a GUI. Works inside the jupyter notebook.
https://paddymul.github.io/buckaroo/
BSD 3-Clause "New" or "Revised" License
227 stars 9 forks source link

Output generated code from low code UI directly into notebook cell #302

Open paddymul opened 1 month ago

paddymul commented 1 month ago

Checks

How would you categorize this request. You can select multiple if not sure

Low Code UI

Enhancement Description

When you add commands to the low code UI, the python code should be injected into the next notebook cell from where the widget was embedded.

Pseudo Code Implementation

This code creates a new cell in a place related to the current cursor position

from IPython.core.getipython import get_ipython

def create_new_cell(contents):
    shell = get_ipython()
    payload = dict(
        source='set_next_input',
        text=contents,
        replace=False,
    )
    return shell.payload_manager.write_payload(payload, single=False)

Prior Art

https://discourse.jupyter.org/t/im-trying-to-figure-out-a-couple-of-cell-operations-from-python/29276

https://github.com/jtpio/ipylab https://github.com/jupyterlab/jupyterlab/issues/13080 https://github.com/jupyterlab/jupyterlab/issues/5789