Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the Datashader library.
Matplotlib
import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing matplotlib instead of datashader.
Using pandas or numpy which are not for big data visualization.
✗ Incorrect
Datashader is imported using import datashader.
2fill in blank
mediumComplete the code to create a canvas with Datashader for a 1000x1000 pixel plot.
Matplotlib
canvas = datashader.Canvas([1]=1000, [2]=1000)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'size' or 'shape' which are not parameters for Canvas.
Confusing width and height.
✗ Incorrect
The Canvas object uses width and height to set pixel dimensions.
3fill in blank
hardFix the error in the code to aggregate points using Datashader's points method.
Matplotlib
agg = canvas.points(df, x='x', y='y', [1]='value')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'agg' or 'agg_func' which are not valid parameters.
Misspelling the parameter name.
✗ Incorrect
The correct parameter name is agg_col to specify the column to aggregate.
4fill in blank
hardFill both blanks to create a HoloViews Points plot and display it.
Matplotlib
import holoviews as hv hv.extension('matplotlib') points = hv.Points(df, kdims=[[1]], vdims=[[2]]) points.opts(color='blue', size=5)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping key and value dimensions.
Using 'index' which is not a data column.
✗ Incorrect
In HoloViews, kdims are key dimensions like 'x', and vdims are value dimensions like 'value'.
5fill in blank
hardFill all three blanks to create a Datashader aggregate and convert it to an image with HoloViews.
Matplotlib
agg = canvas.points(df, x=[1], y=[2], agg_col=[3]) img = hv.Image(agg) img.opts(cmap='viridis')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'count' as agg_col which is not a data column.
Mixing up x and y parameters.
✗ Incorrect
The x and y parameters specify coordinates, and agg_col specifies the data column to aggregate.