MariaDB / mariadb_kernel

A MariaDB Jupyter kernel
BSD 3-Clause "New" or "Revised" License
30 stars 21 forks source link

Add %%python cell magic command #6

Open robertbindar opened 3 years ago

robertbindar commented 3 years ago

The use case I currently see for this magic command is to allow users to customize as much as possible the charts they can generate based on the last query result in a notebook. They can do this by either using some advanced features of the matplotlib library that we'll probably never be able to provide or by using a totally different charting library like Altair.

Initially this magic command should allow users to execute arbitrary python code in a notebook cell and the result of the last executed query should be present in the python context of this particular %%python cell.

Such a cell might look something like:

%%python
import altair as alt

# generate heatmap based on last query data
# last_select is a pandas DataFrame that kernel makes available for this cell
alt.Chart(last_select).mark_rect().encode(
    x='x:O',
    y='y:O',
    color='z:Q'
)