Public
Edited
Feb 12, 2023
7 forks
Importers
22 stars
Insert cell
Insert cell
Insert cell
py = async (strings, ...expressions) => {
let globals = {};
const code = strings.reduce((result, string, index) => {
if (expressions[index]) {
const name = `x${index}`;
globals[name] = expressions[index];
return result + string + name;
}
return result + string;
}, '');
await pyodide.loadPackagesFromImports(code);
const result = await pyodide.pyodide_py.eval_code_async(
code,
pyodide.toPy(globals)
);
if (result?.toJs) return result.toJs();
return result;
}
Insert cell
// pyodide = {
// const pyodide =
// await import("//cdn.jsdelivr.net/npm/pyodide@0.22.1/+esm");
// return pyodide.loadPyodide({
// indexURL: "https://cdn.jsdelivr.net/npm/pyodide@0.22.1/"
// });
// }
pyodide = {
const pyodide =
await require("https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js");
return pyodide.loadPyodide();
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more