CertSafari
    Snowflake SnowPro Advanced: Data Scientist (DSA-C03)· Lessons

    Domain 2 · Lesson 8/16

    Charting Data in Snowsight and Snowflake Notebooks

    Visualize and interpret the data to present a business case.

    10 min read
    6.75% of exam
    3 sources
    Published 5 Oct 2026
    Docs as of 4 Oct 2026

    What you will be able to do

    • Turn a worksheet result into a Snowsight chart, and bucket and aggregate it without rewriting the query
    • Know which Python graph libraries are ready by default in Snowflake Notebooks and which must be installed from Packages
    • Read a stacked bar chart built with Altair, plotly, seaborn or Streamlit
    • Pass SQL results to Python chart cells, and prepare a notebook for presenting

    1.Charts on worksheet results

    Summary numbers show that a pattern exists. A chart shows the audience where it is. Snowsight's own description of charts is that they turn query results into visualizations that support more informed decisions and make patterns and outliers easy to spot. To make one, open a worksheet, run it, and select Chart above the results table. Snowsight generates a chart from the results automatically. Five chart types are available: bar charts, line charts, scatterplots, heat grids and scorecards. Each query can show one chart type at a time, and you can switch between types from the chart type selector.

    Two panels control the chart. In the Data section you add or remove columns, swap in a different result column, and change how a column is represented. The Appearance section handles styling, and its options depend on the chart type. Bucketing is where most of the interpretation happens. You can regroup a daily series into weekly or monthly buckets without touching the SQL. Date columns can be bucketed by date, week, month or year. Numeric columns can be bucketed by integer values. Each bucket is reduced to a single value using one of seven aggregations: average, count, minimum, maximum, median, mode or sum.

    The sample query used for the chart examples, with :daterange and :datebucket filterssql
    SELECT
      COUNT(O_ORDERDATE) as orders, O_ORDERDATE as date
    FROM
      SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.ORDERS
    WHERE
      O_ORDERDATE = :daterange
    GROUP BY
      :datebucket(O_ORDERDATE), O_ORDERDATE
    ORDER BY
      O_ORDERDATE
    LIMIT 10;

    The chart updates automatically when you re-run the query, as long as the columns it uses are still in the results. If you rename a column, you have to point the chart at the new name, and the chart marks any columns it can't find. Chart generation and data transformations in worksheets can also use compute, so a heavily reworked chart isn't free.

    Checkpoint 1 of 4· Check yourself

    A worksheet returns revenue per customer with an integer column for customer age. In the chart's Data section, how can Snowsight bucket the age column?

    Sources1

    2.Open-source graph libraries in Snowflake Notebooks

    Snowsight charts cover the common cases. When you need more control, Snowflake Notebooks let you use familiar Python visualization libraries. Two are ready as soon as the notebook opens. Streamlit is imported by default, and its version 1.39.0 chart elements give you line, bar and area charts and maps with points. Some Streamlit chart elements aren't supported in Snowflake. Altair comes with Streamlit, and Snowflake Notebooks currently support Altair version 4.0. matplotlib, plotly and seaborn each need one extra step: from the notebook, select Packages, find the library, and select it to install it.

    How each library draws the same penguin bar chart in a notebook
    LibraryAvailabilityBar chart call in the docs example
    AltairImported by default (version 4.0)alt.Chart(df).mark_bar().encode(...)
    StreamlitImported by default (version 1.39.0)st.bar_chart(df, x='measurement', y='value', color='species')
    matplotlibInstall from Packagespivot_df.plot.bar(stacked=True)
    plotlyInstall from Packagespx.bar(df, x='measurement', y='value', color='species')
    seabornInstall from Packagessns.barplot(data=df, x="measurement", hue="species", y="value")
    Altair stacked bar chart: measurement on x, value on y, colored by speciespython
    import altair as alt
    alt.Chart(df).mark_bar().encode(
        x= alt.X("measurement", axis = alt.Axis(labelAngle=0)),
        y="value",
        color="species"
    )

    Reading these charts means reading their encodings. In the Altair example, each bar is one measurement, the bar's height is value, and color separates the species. The stacked bar's total therefore adds the three species together, so it doesn't describe any single penguin. The scales also matter. All measurements share one y-axis, so flipper_length (187.1 to 212.7) dwarfs bill_depth (14.2 to 17.7). Real differences in bill depth between species become nearly invisible. Before you present a chart, check what each axis, each color and each stack adds up to. The matplotlib version needs the data pivoted first, with measurements as the index and species as columns, before pivot_df.plot.bar(stacked=True) can stack it.

    Checkpoint 2 of 4· Exam question

    A fraud team stores transaction amounts in `txns(amount)`. A data scientist wants to flag outliers with Tukey's rule (values more than 1.5 × IQR beyond the quartiles) using only SQL in Snowsight. Which approach implements this correctly?

    Checkpoint 3 of 4· Fill the gap

    Which plotly express function completes this bar chart of the penguin data?

    import plotly.express as px
    px. ? (df, x='measurement', y='value', color='species')

    Sources2

    3.From SQL cell to presented notebook

    A notebook can hold the whole story in one place: SQL cells for summaries, Python cells for charts and Markdown cells for the narrative. Snowflake Notebooks support all three cell types. To chart a SQL result in Python, reference the SQL cell by its name. Calling cell1.to_df() gives a Snowpark DataFrame, and calling cell1.to_pandas() gives a pandas DataFrame you can pass straight to any of the libraries above. Cell names are case-sensitive and must match exactly. References in the other direction are more limited. A SQL cell can embed a Python variable with {{variable}}, but only if the variable is a string. Put quotes around it when it is a value, and leave it bare when it is an identifier such as a column name. You can't reference DataFrames this way.

    Convert the result of a SQL cell named cell1 into a pandas DataFramepython
    my_df = cell1.to_pandas()

    Before you present, use Run all so the audience sees current results. Run all executes cells from top to bottom and stops at the first error, so a SQL syntax error in cell 2 means nothing after it runs. Then, under Show/hide all, choose Show results only. This hides the code and leaves just the output, which suits a business audience. Two limits are worth knowing. Each cell can output at most 20 MB, and anything larger is dropped, so split heavy output across cells. Cell results are visible only to the user who ran the notebook, although they are cached across sessions.

    Checkpoint 4 of 4· Check yourself

    A Python cell holds a pandas DataFrame named top_regions and a string variable region = "EMEA". What can a later SQL cell reference with {{...}}?

    Sources3

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.matplotlib, plotly and seaborn are preinstalled in Snowflake Notebooks just like Altair.Why is that wrong?

      Only Streamlit and the Altair that comes with it are imported by default. The other libraries must be selected and installed from Packages.

      Covered in Open-source graph libraries in Snowflake Notebooks

    2. 2.A SQL cell can query a pandas DataFrame from an earlier Python cell by putting {{df}} in the FROM clause.Why is that wrong?

      Only string-typed Python variables can be referenced in SQL code. To go the other way, from SQL to Python, use cellname.to_pandas() or cellname.to_df().

      Covered in From SQL cell to presented notebook

    3. 3.One worksheet query can show a bar chart and a line chart side by side.Why is that wrong?

      Each query supports a single chart type at a time. You switch types; you don't stack them.

      Covered in Charts on worksheet results

    Practise it for real

    Build a notebook that summarizes data in SQL and charts the result in Python, ready to present

    1. 1.In a SQL cell named cell1, run SELECT 'FRIDAY' as SNOWDAY, 0.2 as CHANCE_OF_SNOW UNION ALL SELECT 'SATURDAY',0.5 UNION ALL SELECT 'SUNDAY', 0.9;

      Why: SQL cells produce results that Python cells can reference by cell name

      You should see: A three-row result table, and the cell shows the warehouse used and the rows returned

    2. 2.In a Python cell, run my_df = cell1.to_pandas()

      Why: Chart libraries take a pandas DataFrame, and to_pandas() converts the SQL cell's result

      You should see: my_df holds the three rows; the cell name must match cell1 exactly, including case

    3. 3.In another Python cell, run import streamlit as st and then st.bar_chart(my_df, x='SNOWDAY', y='CHANCE_OF_SNOW')

      Why: Streamlit is imported by default, so no package install is needed

      You should see: A bar chart with one bar per day

    4. 4.Select Run all, then under Show/hide all choose Show results only

      Why: Run all refreshes every cell from top to bottom, and Show results only hides the code for the audience

      You should see: All cells show green status, and only the table and chart are visible

    Stuck? Get a nudge

    If the chart cell errors, check that the column names in st.bar_chart match the case the SQL result returned.

    Sources

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Charts let you quickly identify and understand patterns and outliers in data.”
      ↩︎ Charts on worksheet results
      “Charts use aggregation functions to determine a single value from multiple data points in a bucket.”
      ↩︎ Charts on worksheet results
      “If a column name changes, you must update the chart to use the new column name.”
      ↩︎ Charts on worksheet results
      “Each query supports one type of chart at a time.”
      ↩︎ Exam trap 3
      “For numeric columns, charts can bucket by integer values.”
      ↩︎ Checkpoint
    2. 2.
      “Snowflake Notebooks currently support Altair version 4.0.”
      ↩︎ Open-source graph libraries in Snowflake Notebooks
      “Some Streamlit chart elements are not supported in Snowflake or might be subject to additional terms.”
      ↩︎ Open-source graph libraries in Snowflake Notebooks
      “To use seaborn, you must install the seaborn library for your notebook:”
      ↩︎ Exam trap 1
      “Altair is imported by default on Snowflake Notebooks as part of Streamlit.”
      ↩︎ Prediction
    3. 3.
      “Choose this option before presenting or sharing a notebook to ensure that the recipients see the most current information.”
      ↩︎ From SQL cell to presented notebook
      “If an error occurs in any cell, execution will halt and subsequent cells will not run.”
      ↩︎ From SQL cell to presented notebook
      “For each cell, only 20 MB of output is allowed.”
      ↩︎ From SQL cell to presented notebook
      “In SQL code, you can only reference Python variables of type string.”
      ↩︎ Exam trap 2
      “In SQL code, you can only reference Python variables of type string.”
      ↩︎ Checkpoint

    Ready to test yourself?

    Practise the 24 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.