Before we can start converting our code with tests, we need to refactor it. We'll start by getting rid of all the global variables.
Let's create a function main with two parameters: year and month.
Move all the code (except read_data) inside main
Make categorical a parameter for read_data and pass it inside main
Now we need to create the "main" block from which we'll invoke the main function. How does the if statement that we use for this looks like?
Hint: after refactoring, check that the code still works. Just run it e.g. for March 2023 and see if it finishes successfully.
To make it easier to run it, you can write results to your local filesystem. E.g. here:
Q1. Refactoring
Before we can start converting our code with tests, we need to refactor it. We'll start by getting rid of all the global variables.
Let's create a function main with two parameters: year and month. Move all the code (except read_data) inside main Make categorical a parameter for read_data and pass it inside main Now we need to create the "main" block from which we'll invoke the main function. How does the if statement that we use for this looks like?
Hint: after refactoring, check that the code still works. Just run it e.g. for March 2023 and see if it finishes successfully.
To make it easier to run it, you can write results to your local filesystem. E.g. here:
output_file = f'taxi_type=yellow_year={year:04d}_month={month:02d}.parquet
@Камалиев Тимур What's the question?