Get startedGet started for free

Creating Dask dataframes from CSVs

Previously, you analyzed the Spotify song data using loops and delayed functions. Now you know that you can accomplish the same thing more easily using a Dask DataFrame. Let's see how much easier the same tasks you did earlier are if you do them using these methods instead of loops. First, however, you will need to load the dataset into a Dask DataFrame.

This exercise is part of the course

Parallel Programming with Dask in Python

View Course

Exercise instructions

  • Import the dask.dataframe subpackage as dd.
  • Read all the CSV files in the data/spotify folder using a maximum blocksize of 1MB.
  • Use the dd.to_datetime() function to convert the strings in the 'release_date' column to datetimes.
  • Use the DataFrame's .head() method to show 5 rows of the table.

Hands-on interactive exercise

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

# Import dask dataframe as dd
____

# Load in the DataFrame
df  = ____

# Convert the release_date column from string to datetime
____

# Show 5 rows of the DataFrame
print(____)
Edit and Run Code