Get startedGet started for free

Constructing custom Dask bags

A common use case for Dask bags is to convert some code you have already written to run in parallel. Depending on the code, sometimes it can be easier to construct lists of delayed objects and then convert them to a bag. Other times it will be easier to form a Dask bag early on in the code and map functions over it. Which of these options is easier will depend on your exact code, so it's important that you know how to use either method.

dask has been imported for you, and dask.bag has been imported as db. A list of file names strings is available in your environment as wavfiles.

This exercise is part of the course

Parallel Programming with Dask in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Convert the list of filenames into a Dask bag
filename_bag = ____

# Apply the load_wav() function to each element of the bag
loaded_audio_bag = ____
Edit and Run Code