Skip to content

Add a PowerShell DataFrame and Vega-Lite sample - #95

Merged
TorreyBetts merged 2 commits into
DataficationSDK:mainfrom
eosfor:pr/dataframe-vega-lite-sample
Aug 30, 2026
Merged

TorreyBetts merged 2 commits into
DataficationSDK:mainfrom
eosfor:pr/dataframe-vega-lite-sample

Conversation

@eosfor

@eosfor eosfor commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add an English Palmer Penguins notebook demonstrating PowerShell data analysis with Microsoft.Data.Analysis.DataFrame
  • download the public CSV into memory without adding a dataset file to the repository
  • normalize NA values, apply explicit column types, and render DataFrame previews, schema information, descriptive statistics, and grouped aggregates
  • render three interactive Vega-Lite visualizations: a scatter plot, average body mass by species, and faceted body-mass histograms
  • explain prerequisites and each analysis step with Markdown cells

Why

#94 adds rich DataFrame rendering but intentionally contains no end-user walkthrough. This notebook provides a compact, recognizable dataset and demonstrates how the formatter fits into a complete PowerShell notebook workflow, including interactive browser-native visualization.

The sample keeps its Vega-Lite helper local to the notebook. That makes the workflow usable today without coupling the DataFrame formatter package to a charting library, while leaving room for a dedicated visualization extension later.

User impact

Users can run the notebook from top to bottom to see:

  1. a typed DataFrame loaded from CSV
  2. null handling and schema inspection
  3. descriptive statistics and grouped aggregation
  4. interactive charts with tooltips and PNG/SVG export actions

The DataFrame PowerShell module must be installed before starting Verso. The first run requires internet access for the public dataset and pinned Vega browser libraries. No CSV is written to disk, and the committed notebook contains no saved outputs or embedded dataset copy.

Validation

  • manually ran the complete notebook in the Verso editor
  • dotnet run --project src/Verso.Cli/Verso.Cli.csproj --no-build -- run samples/notebooks/powershell/palmerpenguins/penguins.verso --output none --fail-fast
  • verified all 17 cells execute in a fresh process
  • verified the notebook contains 9 Markdown cells, 8 PowerShell cells, and zero saved outputs
  • validated the .verso document as JSON

@eosfor
eosfor force-pushed the pr/dataframe-vega-lite-sample branch from be2d5bb to e5bb2b8 Compare August 26, 2026 02:45
@eosfor
eosfor marked this pull request as ready for review August 26, 2026 02:47
Store the executed tables and Vega-Lite widgets in the notebook so the read-only viewer can render the sample without running its cells.

Signed-off-by: Andrey Vernigora <[email protected]>
@eosfor

eosfor commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Hello @TorreyBetts

I’m moving this PR back to draft while we clarify whether the observed behavior is part of the intended Verso Viewer contract.

The primary issue can be reproduced using the notebook at commit [44f3dbe](https://www.versonotebooks.com/share/github/eosfor/Verso/blob/44f3dbef959d819f87ad27bada2935b3497d696c/samples/notebooks/powershell/palmerpenguins/penguins.verso):

  1. Open the notebook in the Viewer.
  2. Scroll down to the Vega-Lite examples.
  3. The saved text and table outputs render correctly, but all three Vega charts fail.
  4. The browser console reports errors including vegaEmbed is not defined and Identifier 'binary' has already been declared.

Each saved widget is a self-contained HTML document. Its <head> loads pinned versions of Vega, Vega-Lite, and Vega-Embed, while its inline script renders one chart.

From what I can observe, the Viewer does not preserve the widget’s <head> content and executes inline scripts from separate widget outputs in a shared scope. Consequently, the external libraries are unavailable and top-level const declarations from different widgets collide.

Commit [033316f](https://github.com/DataficationSDK/Verso/commit/033316fb752bc4537bd6df37d1a1322635286dbf) works around this in the notebook helper by:

  • assigning a unique container to each chart;
  • wrapping each widget script in an isolated scope;
  • loading the pinned Vega libraries dynamically through a shared promise.

With that workaround, all three charts render correctly in Chromium. In Safari, however, the first two charts are still blank. Those specifications use Vega-Lite’s width: "container", whereas the final chart uses an explicit numeric width.

viewer

Commit [2024148](https://github.com/DataficationSDK/Verso/commit/2024148942edca88d1340980be349a8d4a1d1233) adds a second workaround by changing the first two charts to an explicit width of 640 pixels. After that change, all three charts render in Safari as well.

viewer

These changes make the sample work with the current Viewer, but the additional widget-specific loading logic and fixed chart widths feel more like compatibility workarounds than a good final solution.

Are the following Viewer behaviors expected?

  • The <head> content of a saved widget is not preserved.
  • Inline scripts from separate widget outputs execute in a shared scope.
  • Vega-Lite charts using width: "container" render as blank in Safari, while an explicit numeric width works.

If these are Viewer limitations rather than intentional behavior, would it be possible to address them in the Viewer? I would prefer not to build these workarounds into the sample if the underlying behavior can be fixed.

@eosfor
eosfor marked this pull request as draft August 26, 2026 04:09
@TorreyBetts

Copy link
Copy Markdown
Contributor

Hi @eosfor,

No, none of that behavior was expected. I fixed the viewer and updated the site so you don't need to build workarounds into the sample. Could you confirm on your side that everything looks right? Assuming it does, then you could drop the two workaround commits.

@eosfor
eosfor force-pushed the pr/dataframe-vega-lite-sample branch from 2024148 to 44f3dbe Compare August 29, 2026 20:35
@eosfor

eosfor commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Hi @TorreyBetts ,

Thank you for fixing this!

I confirmed the original notebook output at 44f3dbe in both Chromium and Safari.

The text and tables render correctly, and all three Vega-Lite charts now render as expected, including the two charts that use width: "container". I also no longer see the previous script errors in Chromium.

I dropped the two workaround commits and force-pushed the cleaned-up branch. The PR now contains only the sample commit and the commit that persists the notebook outputs.

@eosfor
eosfor marked this pull request as ready for review August 30, 2026 01:11
@TorreyBetts

Copy link
Copy Markdown
Contributor

Thanks for another nice contribution. Also, thanks for the Verso mention in your article on powershell.org.

@TorreyBetts
TorreyBetts merged commit 2e06542 into DataficationSDK:main Aug 30, 2026
2 checks passed
@eosfor

eosfor commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

No problem at all, and thanks for merging! If you’re happy with that, I’d love to write a couple more posts with examples using Verso — I have a few ideas in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants