Technical requirements
You can download the datasets and code in the GitHub repository:
- Data: https://github.com/PacktPublishing/Polars-Cookbook/tree/main/data
- Code: https://github.com/PacktPublishing/Polars-Cookbook/tree/main/Chapter07
It is assumed that you have installed the Polars library in your Python environment:
>>> pip install polars
It is also assumed that you have imported it into your code:
import polars as pl
We’ll be using the Trending YouTube Video Statistics dataset (https://github.com/PacktPublishing/Polars-Cookbook/blob/main/data/us_videos.csv) throughout this chapter. Read the data before proceeding to the next steps:
df = pl.read_csv('../data/us_videos.csv', try_parse_dates=True)
Also, look at what the data looks like in the dataset:
df.glimpse(max_items_per_column=2)
The preceding code will produce the following output:
Figure 7.1 – An overview of the DataFrame
...