Experiments using observable plot (repo) within the new Quarto notebooks
- JavaScript for Python Programmers
- Quarto and Observable JS
- Quarto Visual Editor
- Quarto Using Python
- Altair with Quarto
- Moving data from Python/R to OJS
Yes, you can do this using the ojs_define() function (available in both Python and R): https://quarto.org/docs/interactive/ojs/#data-sources JJ Allaire's Response
import pandas as pd
penguins = pd.read_csv("palmer-penguins.csv")
ojs_define(data = penguins)
The call to ojs_define(data = penguins)
says that we want to make a variable named data (with the value of the penguins
data frame) available to OJS
Depending on the visualization library you use, one additional step may be required to consume the data from JavaScript. In this case, the Plot function expects data by row rather than by column, so we transpose()
it before filtering:
filtered = transpose(data).filter(function(penguin) {
return bill_length_min < penguin.bill_length &&
islands.includes(penguin.island);
})
See the article on Data Sources to learn more about the various ways to prepare and read data.