Notebooks, scripts and Quarto documents
Read project data from Python or R, send a result card back to the app, and spot stale cells before they fool you.
What runs in CodeSplash
- Two-sample t-test (Welch / Student, or z test) Verified in Python and R
You will be able to
- Create a notebook, script or document and load a dataset into it
- Turn an analysis into a notebook from its Code tab
- Find cells whose results no longer match their code
Read first
When a dialog isn't enough
ReadAnalyze covers methods with a setup. Notebooks (⌘9) is for everything else: your own code, in Python or R, against the same project data.
New offers six kinds of file:
- Python notebook and R notebook (
.ipynb) - Python script (
.py) and R script (.R) - Quarto document (
.qmd) and R Markdown document (.Rmd)
They are ordinary files in your project folder, so they work outside the app too.
Read your data
In the appCreate a notebook in the language you prefer and run a cell like this. cs.table and cs_table read a dataset by name from the project warehouse.
import codesplash as cs
df = cs.table("Palmer penguins (sample)").df()
df.groupby("species")["body_mass"].mean()library(codesplashr)
df <- cs_table("Palmer penguins (sample)")
aggregate(body_mass ~ species, df, mean)Cells are Code, Markdown or SQL. A SQL cell queries the warehouse directly and can bind its result to a variable. Run a cell with ⌘↵; ⇧↵ also moves to the next one.
Start from a working analysis
In the appYou rarely need to start from an empty notebook. On any analysis, open Code and press Open as notebook. The generated Python or R arrives as cells you can change.
That's how you go past what a dialog offers without rewriting anything. The generated code uses ordinary libraries, plus cs.publish to send a result card back.
What can go wrong?
PredictPredict first
You change a cell near the top of a notebook that filters your data, and you don't re-run the rest. The charts below are still on the page. Do they reflect your new filter?
Reveal
No. Outputs stay where they were until their cell runs again, and a notebook shows you an old answer with no warning of its own. CodeSplash tracks this: More ways to run can run the cells whose code changed, that depend on a cell that re-ran, or that ran before the kernel restarted.
Keep it reproducible
ExploreTry this. Run two cells, where the second uses a variable from the first. Edit the first cell without running it, then open More ways to run and run only the stale cells.
Then use Run all cells, which runs from the top and stops at the first error. If your notebook only works when run out of order, that's what you'll discover here.
Version history keeps snapshots on save and before Run all, so an experiment you regret is one restore away.
The side panels
ReadBeside the cells you'll find Variables (what's in the kernel now, with a viewer for data frames), Outline (headings), and Help (documentation for what's under the cursor).
A notebook runs in its own kernelEngineThe Python or R process that runs an analysis; both produce the same result card., the process holding your variables. Restart clears them, which is the fastest way to find out what your notebook secretly depends on. Scripts run in a fresh process each time, so they can't have that problem.
Check your understanding
CheckpointCheck yourself
Which line reads a project dataset into R?
Show the answer
Answer: b
Datasets live in the project warehouse. cs_table (Python: cs.table) reads them by name, and cs_publish sends results the other way.
Check yourself
Put these in order to check a notebook really reproduces.
Show the answer
The order:
- Restart the kernel
- Press Run all cells
- Compare the results with what you reported
Restarting clears hidden state; running from the top shows whether the order on the page is enough to reach your result.
Choose your format
ReflectWhich fits your next piece of work: a notebook for exploring, a script for something that runs on a schedule, or a Quarto document for prose with results in it? If you're not sure, start with a notebook. Convert and Export in the file's menu can move it later.
To share a notebook with someone who doesn't use CodeSplash, Export… in its toolbar saves it as an HTML page, a PDF or a Jupyter notebook (.ipynb).
Recap
Recap- Notebooks, scripts and documents use your project's data through
cs.table/cs_table. - Open as notebook on any analysis's Code tab is the quickest way past a dialog.
- Outputs can go stale. Run the stale cells, or restart and run all.
Concepts in this lesson