Hackers and Slackers

Code Snippet Corner

Real-world examples of Python being used to solve complex data problems, primarily using Jupyter notebooks.

Code Snippet Corner: Tuning Machine Learning Hyperparameters with Binary Search

Tune the n_estimators parameter in for a Random Forests classifier in scikit-learn in Python

Ah, hyperparameter tuning.  Time & compute-intensive.  Frequently containing weird non-linearities in how changing a parameter changes the score and/or the time it takes to train the model.

RandomizedSearchCV goes noticeably faster than a full GridSearchCV but it still takes

Code Snippet Corner Author imageMatthew Alhonte Author imagematt Sep 03
Read

Importing Excel Datetimes Into Pandas II

Pandas and Excel Pt. 2

What if, like during my data import task a few months back, the dates & times are in separate columns?  This gives us a few new issues.  Let's import that Excel file!

import pandas as pd
import xlrd
import datetime
Pandas Author imageMatthew Alhonte Author imagematt Aug 20
Read

Importing Excel Datetimes Into Pandas

Pandas & Excel, Part 1

Different file formats are different!  For all kinds of reasons!

A few months back, I had to import some Excel files into a database. In this process I learned so much about the delightfully unique way Excel stores dates &

Pandas Author imageMatthew Alhonte Author imagematt Aug 13
Read

Lazy Pandas and Dask

Picking Low-Hanging Fruit With Dask

Ah, laziness.  You love it, I love it, everyone agrees it's just better.

Flesh-and-blood are famously lazy.  Pandas the package, however, uses Eager Evaluation.  What's Eager Evaluation, you ask?  Is Pandas really judgey, hanging out on the street corner and

Pandas Author imageMatthew Alhonte Author imagematt Aug 06
Read

All That Is Solid Melts Into Graphs

Reshaping Pandas dataframes with a real-life example, and graphing it with Altair

Last few Code Snippet Corners were about using Pandas as an easy way to handle input and output between files & databases.  Let's shift gears a little bit!  Among other reasons, because earlier today I discovered a package that exclusively

Python Author imageMatthew Alhonte Author imagematt Jul 30
Read