Time to Code
Explore advanced data processing techniques by grouping raw data, using decorators to count subsets, and extracting meaningful statistics from a food dataset. Understand data cleaning, filtering, and anonymous functions to analyze gender, drink preferences, exercise patterns, and academic-job balance using Python data structures.
We'll cover the following...
Challenging questions❓
To provide you with a headstart, we have attached the dataset file food.csv at the backend, and have read it in a list: data. Here’s the snippet:
We have hard-coded required_columns: a list containing the columns we’ll need, and leaving out the rest.
Let’s start the fun!
Task 1: Group the data
This task is not as simple as it seems. The data is in the raw format. You can try printing the data and can see it for yourself. One can’t make any sense out of it. First, we have a list of all the column names. Then, we have a separate list for every student’s response containing values to those columns; keeping a tally of which value corresponds to which column is hectic.
Your first task is to write a function group_values_with_columns to group the data. By grouping, we mean attaching values with their respective columns. You need to do something ...