Week of January 10th
I’m getting close to my final exams so most of my time will go towards studying. Accordingly, expect a hiatus from blog postings.
What I did
- pandas apply and map functions practice.
- WSL2 still has the problem where copying/pasting from windows into the linux subsystem directory results in the creation of Zone.Identifer files. It’s really annoying because it makes it harder to find the files for which you are actually looking, and nothing breaks if you simply delete these .Indentifier files. I know I fixed the problem before, but I had to look up how to recursively delete them again. This time I’ve posted the code here, in case I need to look it up again.
What I Learned
- How to capture data outputted as a print instead of a returned value (some python package functions do this)
- You used to have to create a capturing class and then override the dunder methods for enter and exit, but now you can use
contextlib
.
- You used to have to create a capturing class and then override the dunder methods for enter and exit, but now you can use
import io
from contextlib import redirect_stdout
f = io.StringIO()
with redirect_stdout(f):
do_something(my_object)
out = f.getvalue()
- To recursively delete a file extension in Bash (in this case the Zone.Identifier files in WSL2), use the following code while in the uppermost directory in which you want the files deleted:
find . -type f -name '*.Identifier' -delete
- Selecting subsets in pandas has really specific syntax. For example:
df[(df.item == 'Hamburger') & (df.quantity == 1)]
- Note how you need the parentheses and it’s only a single &, not too, or “and.”
What I will do next
- More
Pandas
practice to stay sharp, while dealing while the bulk of my time now has to be focused on exams.