Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new altair-python/ sample-code folder to support the Real Python “Altair: Declarative Charts With Python” tutorial, including several standalone chart examples.
Changes:
- Added a new article folder with a README linking to the tutorial.
- Added multiple Altair chart example scripts (bar chart, basic scatter, encoded scatter, faceting, and linked views).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| altair-python/README.md | Adds the article-specific README and link to the tutorial. |
| altair-python/steps.py | Simple pandas DataFrame + Altair bar chart example. |
| altair-python/scatter_basic.py | Basic scatter plot example using the movies dataset. |
| altair-python/scatter_encoding_channels copy.py | Scatter plot with additional encoding channels (color/size/tooltip). |
| altair-python/scatter_faceted.py | Faceted scatter plot example using column=. |
| altair-python/scatter_connected.py | Linked selection example combining scatter + filtered bars. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import altair as alt | ||
| from altair.datasets import data |
There was a problem hiding this comment.
The filename contains a space and the suffix "copy", which makes it awkward to import/execute from shells and looks like an accidental duplicate. Please rename this file to a conventional slug/snake-case name without spaces (and without "copy"), e.g. "scatter_encoding_channels.py".
| color=( | ||
| alt.when(brush) | ||
| .then("Major Genre:N") | ||
| .otherwise(alt.value("lightgray")), | ||
| ), |
There was a problem hiding this comment.
The extra parentheses around the color= expression are unnecessary and make this already-long line harder to read. Consider removing the redundant parentheses and letting the formatter wrap the chained call for readability.
| color=( | |
| alt.when(brush) | |
| .then("Major Genre:N") | |
| .otherwise(alt.value("lightgray")), | |
| ), | |
| color=alt.when(brush) | |
| .then("Major Genre:N") | |
| .otherwise(alt.value("lightgray")), |
| x="Day", | ||
| y="Steps", |
There was a problem hiding this comment.
Unlike the other examples in this folder, the encodings here don’t specify field types (e.g. Day:N, Steps:Q). Making the types explicit keeps the example consistent and avoids relying on Altair’s type inference if the data source changes.
| x="Day", | |
| y="Steps", | |
| x="Day:N", | |
| y="Steps:Q", |
altair-python/scatter_basic.py
Outdated
| "IMDB Rating", | ||
| "Major Genre", | ||
| "MPAA Rating", |
There was a problem hiding this comment.
This dropna() filters on columns that aren’t used in this chart (e.g. IMDB Rating, Major Genre, MPAA Rating), which changes which points appear in the basic scatter plot. Consider dropping NAs only for the fields you actually encode here, or add a short comment explaining why you’re pre-filtering extra columns for consistency with later examples.
| "IMDB Rating", | |
| "Major Genre", | |
| "MPAA Rating", |
altair-python/scatter_connected.py
Outdated
| "Worldwide Gross", | ||
| "IMDB Rating", | ||
| "Major Genre", | ||
| "MPAA Rating", |
There was a problem hiding this comment.
This dropna() filters on "MPAA Rating", but this script doesn’t use that field in any encoding. That will remove additional rows and can change the resulting chart. Consider limiting the subset to only the fields used in this script (or add a comment explaining the broader filtering choice).
| "MPAA Rating", |
| "Worldwide Gross", | ||
| "IMDB Rating", | ||
| "Major Genre", | ||
| "MPAA Rating", |
There was a problem hiding this comment.
This dropna() filters on "MPAA Rating", but this script doesn’t use that field in any encoding. That will remove additional rows and can change the resulting chart. Consider limiting the subset to only the fields used in this script (or add a comment explaining the broader filtering choice).
| "MPAA Rating", |
Where to put new files:
my-awesome-articleHow to merge your changes: