What you will be able to do
- Pick the right chart for a single feature from its type: a histogram for continuous, a bar or pie chart for categorical
- Build a box chart that compares a continuous feature across categories and read its median, quartiles, whiskers and outlier points
- Use a scatter or bubble chart for two continuous features, and a heatmap or pivot table for two categorical features
- Create and configure these charts from display() output with the notebook visualization editor, and know which chart types truncate large results
Key concept
Chart type follows feature type — Whether a feature is continuous (a measured number) or categorical (one of a set of discrete labels) decides which chart can show it honestly. Continuous values get binned or plotted along a numeric axis, and categorical values get one mark per category.
1.Why the feature type decides the chart
Before you impute a column, encode it or transform it, you need to see it, and the right picture depends on what kind of values it holds. A continuous feature such as a price or a temperature can take any value in a range. A categorical feature such as a region or an order priority takes one of a fixed set of labels. The Databricks chart editor makes the same split on every axis: a categorical scale for discrete values, and a linear or logarithmic scale for continuous ones. By default it picks the scale from the data type of the column you put on that axis.
In a notebook, every chart starts from a result table. Calling display() on a DataFrame renders the table, then + above the result and Visualization opens the editor. There you pick a type from the Visualization Type drop-down, map columns to the axes and click Save, and the chart becomes a tab in the cell output. This works for a pandas DataFrame as well: the EDA tutorial calls display(df) on a pandas frame and builds charts from that output table.
from pyspark.sql.functions import hour, col
pickupzip = '10001' # Example value for pickupzip
df = spark.table("samples.nyctaxi.trips")
result_df = df.filter(col("pickup_zip") == pickupzip) \
.groupBy(hour(col("tpep_dropoff_datetime")).alias("dropoff_hour")) \
.count() \
.withColumnRenamed("count", "num")
display(result_df)| What you are looking at | Chart | What the chart shows |
|---|---|---|
| One continuous feature | Histogram | How often values fall in each bin across the range |
| One categorical feature | Bar or Pie | A count or total per category, or each category's share |
| Continuous feature by categorical feature | Box | Quartiles and spread of the numbers, one box per category |
| Two continuous features | Scatter or Bubble | One point per row; a bubble's size encodes a third metric |
| Two categorical features | Heatmap or Pivot table | A grid of category pairs with an aggregated value in each cell |
Checkpoint 1 of 9· Fill the gap
This cell builds a result set that you then want to chart in the notebook's visualization editor. Which function goes in the blank so that the cell output has a result table you can add a Visualization to?
from pyspark.sql.functions import hour, col
pickupzip = '10001' # Example value for pickupzip
df = spark.table("samples.nyctaxi.trips")
result_df = df.filter(col("pickup_zip") == pickupzip) \
.groupBy(hour(col("tpep_dropoff_datetime")).alias("dropoff_hour")) \
.count() \
.withColumnRenamed("count", "num")
? (result_df)display() renders the DataFrame as a result table. You then click + above that table and choose Visualization to open the chart editor. print() only writes the DataFrame's text representation, and dbutils.data.summarize produces a data profile, not the result table you chart.
Source: docs.databricks.comCheckpoint 2 of 9· Exam question
A data scientist loads a table into a pandas DataFrame in a Databricks notebook and wants to see how many rows fall into each of the five values in the region column. Which visualization best shows this?
Correct answer: A — Create a bar chart with one bar per region value, so each bar's height shows the count of rows in that category.
- A. A bar chart with one bar per category is the standard way to display counts of a categorical feature like
region, since each bar's height directly encodes that category's frequency. - B. Histograms bin continuous numeric values into equal-width intervals;
regionis a categorical column with discrete labels, not a continuous quantity, so binning it numerically does not produce a meaningful chart. - C. Plotting a category against row index does not summarize frequency at all — it scatters points by the arbitrary order rows appear in, which tells the viewer nothing about how many rows belong to each region.
- D. Box plots summarize the spread and outliers of a continuous numeric variable using quartiles;
regionhas no numeric quartiles to compute, so a box plot cannot be built directly from a categorical label like this.
2.Histograms show the shape of a continuous feature
A histogram is the chart for one continuous feature. It splits the value range into bins and plots how many rows land in each one. The result is a bar chart in which you choose the number of bars, so the shape of the distribution is visible at a glance: values packed into a few ranges, spread out evenly, piled up on one side, or split into two humps. That shape is what you want to see before deciding how to fill gaps in a column like transaction_amount.
In the notebook editor a histogram needs only two settings: the X Column to plot and the Number of Bins. The X axis scale can be set to Linear or Logarithmic, among other options. Histograms aggregate on the backend, so results over 64K rows are counted in full rather than truncated. In PySpark, df.plot.hist() draws the same chart directly from a Spark DataFrame. When you name no column it plots all the numeric ones, and it uses 10 bins unless you pass bins.
data = [(5.1, 3.5, 0), (4.9, 3.0, 0), (7.0, 3.2, 1), (6.4, 3.2, 1), (5.9, 3.0, 2)]
columns = ["length", "width", "species"]
df = spark.createDataFrame(data, columns)
df.plot.hist(bins=4)The tempting alternatives all fail on a continuous column, each for a different reason. A bar chart with one bar per unique dollar amount produces thousands of bars of height one, because continuous values almost never repeat exactly. A line chart is for a metric changing over time. Joining raw values in whatever order the rows happen to sit draws a zigzag that says nothing about the distribution. A pie chart shows proportions between a few metrics, so slicing a column's total into one wedge per row shows neither skew nor peaks.
Checkpoint 3 of 9· Check yourself
Before imputing missing values in the continuous column transaction_amount, you want to see whether its values are skewed, bimodal or spread evenly. Which notebook visualization should you configure?
A histogram groups the numeric range into bins and counts the rows in each one, which shows the shape of the distribution. Continuous amounts almost never repeat, so one bar per distinct value gives thousands of bars of height one. A line chart in row order draws a meaningless zigzag, and per-row pie wedges show neither skew nor peaks.
“A histogram helps you to understand whether a dataset has values that are clustered around a small number of ranges or are more spread out.”Source: docs.databricks.com
Checkpoint 4 of 9· Exam question
A machine learning engineer wants to understand the overall shape of the distribution of a continuous transaction_amount column — whether it is roughly symmetric, skewed, or bimodal — before choosing an imputation strategy. Which visualization is most appropriate?
Correct answer: A — Plot a histogram of transaction_amount, dividing the value range into bins and showing the count of rows in each bin.
- A. A histogram bins a continuous variable's range into intervals and shows the count in each bin, which is exactly what reveals symmetry, skew, or multiple peaks in
transaction_amount. - B. Treating every unique dollar amount as its own bar produces an unreadable chart with as many bars as distinct values, since it ignores the continuous nature of the variable instead of grouping nearby values into ranges.
- C. Connecting values in row order shows a sequence over an arbitrary index, not a distribution; it reveals nothing about how the values cluster or spread across their range.
- D. A pie chart divides a whole into proportional wedges and is meant for categorical composition, not for showing the shape of a continuous variable's distribution across its range.
3.Bar and pie charts count categorical features
A categorical feature has no numeric range to bin. Its natural picture is one bar per category, where the bar's height is the number of rows (or a summed metric) in that category. For a region column with five values that means five bars, which you can compare by height. A pie chart shows the same per-category numbers as shares of a whole. It suits a handful of categories and is not meant for time series.
You don't have to write a groupBy to get those counts. Bar, pie, line, area, heatmap and histogram charts aggregate inside the visualization. Put the categorical column on the X axis, then set the Y column's aggregation. Numeric columns offer Sum (the default), Average, Count, Count Distinct, Max, Min and Median. String columns offer Count and Count Distinct. The aggregation runs over the entire dataset rather than the first 64,000 rows shown in the table, and you can switch it to try a different view without editing code.
Two bar settings matter when a second categorical column is involved. Group by draws each group in its own colour with its own legend entry. Stacking either layers the groups on top of each other to show cumulative totals or places them side by side. The pie example in the Databricks gallery puts the categorical o_orderpriority on X and sums o_totalprice per slice.
Checkpoint 5 of 9· Check yourself
Your notebook result table has one row per order, with a string column region. The query has no groupBy. You want to see how many orders fall in each region. How should you set up the chart?
A categorical column gets one bar per category, and the bar chart can count the rows itself through the Y column's aggregation, so you don't need a groupBy. Histograms bin numeric ranges. String columns offer only Count and Count Distinct, not Sum. The aggregation also runs over the entire dataset, not only the first 64,000 rows.
“For bar, line, area, pie, and heatmap charts, you add aggregation directly in the visualization rather than modifying the query to add an aggregation column.”Source: docs.databricks.com
4.Box charts summarise a continuous feature, optionally by category
A box chart reduces a numeric column to five landmarks. The box runs from the first quartile (Q1) to the third (Q3), so its height is the interquartile range, and a line inside it marks the median. In a box-and-whisker plot, the whiskers reach out at most 1.5 × IQR from the edges of the box, and any point beyond them is drawn as a separate dot. That makes the box chart the one plot that shows the median, the IQR and the suspicious extremes together. Removing those points is a separate step, covered in Outliers: standard-deviation bounds and 1.5×IQR fences.
data = [
("A", 50, 55),
("B", 55, 60),
("C", 60, 65),
("D", 65, 70),
("E", 70, 75),
("F", 10, 15),
("G", 85, 90),
("H", 5, 150),
]
columns = ["student", "math_score", "english_score"]
df = spark.createDataFrame(data, columns)
df.plot.box()Where a box chart really earns its place is comparing a continuous feature across categories. Each category gets its own box, so differences in typical value, spread and skew sit side by side. In the notebook editor, a vertical box chart takes a categorical column on X and a numeric column on Y, and the boxes are grouped by X. Turning on Horizontal Chart swaps the roles. Show all points plots every value instead of the summary box.
That row limit is the box chart's practical catch. Bar, histogram, heatmap, scatter-style bubble and pie charts aggregate on the backend and see the whole result, but a box chart built from a large table summarises only its first 64,000 rows. The quartiles and outlier dots then describe a slice of the data, not the whole column. To get a box chart that covers everything, reduce the result in the query first, for example by filtering, so it fits under the limit.
Checkpoint 6 of 9· Match them up
You are setting up a notebook box chart to compare delivery_time_hours across shipping regions. Match each box chart setting to what it should hold or do.
Tap a term, then the definition that fits it.
A vertical box chart groups by the categorical X column and summarises the numeric Y column. Horizontal Chart swaps the two roles, and Show all points replaces the box with the individual values.
“X column: X axis values. For a vertical chart, choose a categorical column. For a horizontal chart, choose a number column.”Source: docs.databricks.com
Checkpoint 7 of 9· Exam question
An analyst suspects the continuous delivery_time_hours column has a handful of unusually large values that could be outliers, and wants a single plot that shows the median, the interquartile range, and any points that fall far outside that range. Which visualization satisfies this?
Correct answer: A — A box plot of delivery_time_hours, drawing the median line, the interquartile box, and points beyond the whiskers as outliers.
- A. A box plot is built specifically from the median and the interquartile range, and it plots any value beyond 1.5 times the IQR from the box as an individual outlier point, matching every requirement in the scenario.
- B. A histogram summarizes the count of values per bin, which shows overall shape but does not compute or draw a median line or explicitly flag individual outlier points.
- C. A bar chart of a continuous column like delivery time treats each raw value as a separate category and provides no summary statistic such as a median or interquartile range.
- D. A pie chart shows proportional shares of a total and has no mechanism for representing quartiles, a median, or outlier points along a numeric range.
5.Scatter and bubble charts relate two continuous features
When both features are continuous, a scatter chart puts one on each axis and draws a point per row. A cloud of points shows what a single number cannot: whether the relationship is a straight line, a curve, two separate clusters, or a few points far from the rest. Pearson correlation for two continuous features summarises how strong the linear trend is in one coefficient. The scatter plot is how you check whether a linear summary fits at all, and it also brings outliers to the surface.
Scatter and bubble charts share the general chart options in the editor, including Group by, which colours points by a categorical column so you can add a third, discrete dimension. A bubble chart is a scatter chart where the size of each marker encodes another metric. The Databricks example plots l_quantity against l_extendedprice, groups by l_returnflag and sizes the bubbles by l_tax. Outside the editor, df.plot.scatter(x=..., y=...) draws a scatter from a Spark DataFrame, and plotly works on pandas data, as in the EDA tutorial:
# Plot renewable share vs. greenhouse gas emissions over time
fig = px.scatter(top_emitters_data, x='renewable_share', y='greenhouse_gas_emissions',
color='country', title="Impact of Renewable Energy on Emissions for Top Emitters")
fig.show()Reading that chart, the tutorial found that the top emitters' emissions rose along with their renewable share, meaning total consumption grew faster than renewables. North America was the exception: its emissions held roughly flat while its renewable share kept climbing. Colouring by country is what made that exception visible. Pooled into one correlation coefficient, it would vanish.
Checkpoint 8 of 9· Fill the gap
Both renewable_share and greenhouse_gas_emissions are continuous. You want to see how emissions move as the renewable share changes, coloured by country. Which plotly function completes the call?
# Plot renewable share vs. greenhouse gas emissions over time
fig = px. ? (top_emitters_data, x='renewable_share', y='greenhouse_gas_emissions',
color='country', title="Impact of Renewable Energy on Emissions for Top Emitters")
fig.show()When both features are continuous, a scatter chart puts one on each axis and draws a point per row, so you can see the shape of the relationship and any outliers. A histogram bins only one continuous feature. A box chart summarises a numeric column for each category, and a bar chart counts or totals per category.
Source: docs.databricks.com6.Heatmaps and pivot tables cross two categorical features
Two categorical features form a grid, one category on each axis, and the question is what happens in each cell. A heatmap answers it with colour. In the Databricks example, o_orderpriority is on X and o_orderstatus on Y, and each cell is coloured by the average o_totalprice. Warm colours such as orange or red usually mark the highest values, and cool blues and purples the lowest. Choose Count as the colour aggregation and the grid becomes a visual Contingency table (crosstab) for two categorical features, with the most common combinations glowing brightest.
A pivot table visualization gives the same cross-tabulation as numbers instead of colour. You drag one column to rows and another to columns, and pick a cell aggregation. The example crosses l_returnflag with l_shipmode, sums l_quantity, and can colour cells by value. The current pivot table aggregates on the backend, but Pivot table (legacy) truncates past 64,000 rows just as the box chart does. A stacked bar chart with Group by set to the second category is a third option when you want to read counts as bar heights.
Checkpoint 9 of 9· Match them up
To cross two categorical columns, order_priority and order_status, over a 500,000-row orders table, you are considering four notebook visualizations. Match each one to how it presents the grid of category pairs.
Tap a term, then the definition that fits it.
A heatmap shows each category pair's aggregated value as a colour, and a pivot table shows it as a number. The current pivot table aggregates on the backend over the full result. The legacy pivot table stops at 64,000 rows, so on this table it would summarise only part of the data. A stacked bar chart grouped by the second category shows the counts as bar heights.
“However, Pivot table (legacy) only support aggregation for up to 64,000 rows. If a dataset is larger than 64,000 rows, data will be truncated.”Source: docs.databricks.com
Sources4
Practise it for real
Chart a computed result set with the notebook visualization editor and see what in-editor aggregation does.
1.Run the Python snippet that filters samples.nyctaxi.trips to pickup_zip 10001, groups by dropoff_hour, and ends with display(result_df).
Why: Every notebook visualization is built from a displayed result table.
You should see: A results table with the columns dropoff_hour and num.
2.Click + above the result, select Visualization, and choose Bar in the Visualization Type drop-down.
Why: This opens the visualization editor on that result.
You should see: The editor opens with a chart preview.
3.Set the X column to dropoff_hour and the Y column to num with the Sum aggregation, then click Save.
Why: Each bar then shows the trip count for one drop-off hour.
You should see: A bar chart saved as a new tab in the cell output.
4.Edit the visualization from the arrow on its tab and change the Y aggregation from Sum to Count.
Why: In-editor aggregation lets you change the summary without touching the code.
You should see: Each bar now counts the rows per hour (1 per hour here, since the query already grouped them) instead of summing num.
Stuck? Get a nudge
If the editor says the visualization uses an old configuration, re-create it before setting an aggregation.
Sources
(8)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Linear or logarithmic should be chosen when each value is continuous, for example, temperatures.”
↩︎ Why the feature type decides the chart“When stacked, values belonging to multiple series will be layered on top of each other to show cumulative values.”
↩︎ Bar and pie charts count categorical features“Categorical scale types should be selected when each value belongs to a discrete category, for example a geographical region.”
↩︎ Key concept - 2.https://docs.databricks.com/aws/en/visualizationsOfficial docs
“To create a visualization, click + above a result and select Visualization to open the visualization editor.”
↩︎ Why the feature type decides the chart“Or from the following for string types: Count Count Distinct”
↩︎ Bar and pie charts count categorical features“The aggregation applies to the entire dataset, not just the first 64,000 rows displayed in a table.”
↩︎ Bar and pie charts count categorical features“For bar, line, area, pie, and heatmap charts, you add aggregation directly in the visualization rather than modifying the query to add an aggregation column.”
↩︎ Checkpoint - 3.
“In a new cell, use display(df) to display the dataset as a table.”
↩︎ Why the feature type decides the chart“For instance, scatter plots can highlight outliers, while time series plots can reveal trends and seasonality.”
↩︎ Scatter and bubble charts relate two continuous features“North America is an exception in that its greenhouse gas emissions stayed relatively constant throughout the years as its renewable share continued to increase.”
↩︎ Scatter and bubble charts relate two continuous features - 4.
“whether a dataset has values that are clustered around a small number of ranges or are more spread out”
↩︎ Histograms show the shape of a continuous feature“A histogram is displayed as a bar chart in which you control the number of distinct bars (also called bins).”
↩︎ Histograms show the shape of a continuous feature“Line charts present the change in one or more metrics over time.”
↩︎ Histograms show the shape of a continuous feature“Pie charts show proportionality between metrics. They are not meant for conveying time series data.”
↩︎ Bar and pie charts count categorical features“The box chart visualization shows the distribution summary of numerical data, optionally grouped by category.”
↩︎ Box charts summarise a continuous feature, optionally by category“Bubble charts are scatter charts where the size of each point marker reflects a relevant metric.”
↩︎ Scatter and bubble charts relate two continuous features“Heatmap charts blend features of bar charts, stacking, and bubble charts allowing you to visualize numerical data using colors.”
↩︎ Heatmaps and pivot tables cross two categorical features“A pivot table visualization aggregates records from a query result into a new tabular display.”
↩︎ Heatmaps and pivot tables cross two categorical features“However, Pivot table (legacy) only support aggregation for up to 64,000 rows.”
↩︎ Heatmaps and pivot tables cross two categorical features“Box charts only support aggregation for up to 64,000 rows. If a dataset is larger than 64,000 rows, data will be truncated.”
↩︎ Exam trap 3“A histogram helps you to understand whether a dataset has values that are clustered around a small number of ranges or are more spread out.”
↩︎ Checkpoint“Box charts only support aggregation for up to 64,000 rows. If a dataset is larger than 64,000 rows, data will be truncated.”
↩︎ Prediction“However, Pivot table (legacy) only support aggregation for up to 64,000 rows. If a dataset is larger than 64,000 rows, data will be truncated.”
↩︎ Checkpoint - 5.
“Number of Bins: Number of bins in which to display the data.”
↩︎ Histograms show the shape of a continuous feature - 6.
“Number of histogram bins to use. Default: 10.”
↩︎ Histograms show the shape of a continuous feature“If None (default), all numeric columns are used.”
↩︎ Exam trap 1 - 7.
“Outliers are plotted as separate dots.”
↩︎ Box charts summarise a continuous feature, optionally by category“The box extends from the Q1 to Q3 quartile values of the data, with a line at the median (Q2).”
↩︎ Exam trap 2 - 8.
“Y columns: Y axis values. For a vertical chart, choose a number column.”
↩︎ Box charts summarise a continuous feature, optionally by category“X column: X axis values. For a vertical chart, choose a categorical column.”
↩︎ Exam trap 4“X column: X axis values. For a vertical chart, choose a categorical column. For a horizontal chart, choose a number column.”
↩︎ Checkpoint