This repo was copied from pandas_cookbook. Do have a look at the original.
Your job is to turn this pandas cookbook into a polars cookbook. Some good resources for polars are:
- The official documentation here
- Calmcode.io tutorial here
- Feel free to use chat bots like ChatGPT, Claude, or Gemini. Or GitHub Copilot.
There are several chapters that guide you through how to use pandas in the cookbook folder. It will be your job to create a cookbook for polars.
- Fork this repo.
- Clone the forked repo and open it in VS Code.
- Create a virtual environment from the environment.yml:
- Select this environment as your interpreter in VS Code.
Create a virtual environment from the environment.yml
a. Open the terminal
b. Go to your workspace folder if you are not already in it: cd path_to_repo
c. Then type conda env create -f environment.yml
Set Up VS Code to Use the New Environment
a. Open your project folder in VS Code.
b. Press Ctrl+Shift+P
(or Cmd+Shift+P
on macOS) to open the Command Palette.
c. Type "Python: Select Interpreter" and select it.
d. From the list, choose the interpreter that matches your new Conda environment.
It should look something like polars_cookbook
.
e. VS Code will now use this environment for running Python code in this project.
Verify the Setup
Open a Python file or create a new one. In the bottom-left corner of VS Code, you should see the name of your Conda environment. This confirms that VS Code is using the correct environment.
- Create a branch called "chapter_1"
- Switch to this branch
- Open the first chapter in the cookbook here
- Complete the to-dos in the cells, which means rewriting the pandas code into polars.
- For every to-do, use the git flow and add, commit, push
- Once you have done your first commit and pushed it to the remote, go to your repo on GitHub
- GitHub will show you that you created a new branch and ask you to do a pull request. Make a pull request.
- Having started your pull request, have a look at your commit. Can you easily identify the changes you have made?
- Finish all the to-dos in chapter 1 (do not forget to add, commit, push after every to-do)
- Once you have done all to-dos in chapter 1, go back to GitHub and merge your branch into main.
- After merging in GitHub, don't forget to pull the changes locally. (First change to the main branch, and then do a git pull)
Above you have seen that doing pull requests with jupyter notebooks are not very visually pleasing.
For this reason, the further chapters are no longer jupyter notebooks but python files. We use a trick, however. You can get all the beauty of the interactiveness of jupyter notebooks using # %%
.
Now, for the remaining chapters:
- Create a branch for each chapter.
- Complete all to-dos and add, commit, push for each to-do you complete.
- Have a look at your commits. Can you see how much easier it is to analyse your changes now?
- Once finished, merge your branch into main.
- Proceed to the next chapter.