Code Snippet Corner

Real-world examples of Python snippets used to solve complex data problems, primarily leveraging Pandas and related libraries.

Being REALLY Lazy With Multiple Aggregations in Pandas

Being REALLY Lazy With Multiple Aggregations in Pandas

Perform multiple aggregate functions simultaneously with Pandas 0.25

Matthew Alhonte
Matthew Alhonte
Code Snippet Corner
Splitting Columns With Pandas

Splitting Columns With Pandas

Split columns containing multiple values in your Pandas DataFrame into multiple columns, each containing a single value.

Matthew Alhonte
Matthew Alhonte
Code Snippet Corner
Recasting Low-Cardinality Columns as Categoricals

Recasting Low-Cardinality Columns as Categoricals

Downcast strings in Pandas to their proper data-types using HDF5.

Matthew Alhonte
Matthew Alhonte
Code Snippet Corner
Removing Duplicate Columns in Pandas

Removing Duplicate Columns in Pandas

Dealing with duplicate column names in your Pandas DataFrame.

Matthew Alhonte
Matthew Alhonte
Code Snippet Corner
Downcast Numerical Data Types with Pandas

Downcast Numerical Data Types with Pandas

Using an Example Where We Downcast Numerical Columns.

Matthew Alhonte
Matthew Alhonte
Code Snippet Corner
Using Random Forests for Feature Selection with Categorical Features

Using Random Forests for Feature Selection with Categorical Features

Python helper functions for adding feature importance, and displaying them as a single variable.

Matthew Alhonte
Matthew Alhonte
Code Snippet Corner
Tuning Random Forests Hyperparameters: min_samples_leaf

Tuning Random Forests Hyperparameters: min_samples_leaf

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

Matthew Alhonte
Matthew Alhonte
Code Snippet Corner
Tuning Random Forests Hyperparameters: max_depth

Tuning Random Forests Hyperparameters: max_depth

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

Matthew Alhonte
Matthew Alhonte
Code Snippet Corner