#Code Snippet Corner

Code Snippet Corner

Your weekly dose of Python tidbits and Jupyter notebooks to get you feeling saucy.

Using Pandas and SQLAlchemy to Simplify Databases

1: Using Pandas and SQLAlchemy to Simplify Databases

Use SQLAlchemy with PyMySQL to make database connections easy.
Getting Conda Envs (And Environment Variables!) To Play Nicely With Cron

2: Getting Conda Envs (And Environment Variables!) To Play Nicely With Cron

Set up CRON jobs to interact with Conda environments.
A Dirty Way of Cleaning Data (ft. Pandas & SQL)

3: A Dirty Way of Cleaning Data (ft. Pandas & SQL)

Cleaning data in Pandas the dirty way.
Trash Pandas: Messy, Convenient Database Operations via Pandas

4: Trash Pandas: Messy, Convenient Database Operations via Pandas

Using Pandas with databases wrong way, and how to clean it up with SQLAlchemy.
All That Is Solid Melts Into Graphs

5: All That Is Solid Melts Into Graphs

Reshaping Pandas DataFrames with a real-life example, and graphing it with Altair.
Importing Excel Datetimes Into Pandas, Part I

6: Importing Excel Datetimes Into Pandas, Part I

Parse dates and times from Excel .xlsx correctly when using Pandas.
Importing Excel Datetimes Into Pandas, Part II

7: Importing Excel Datetimes Into Pandas, Part II

Import dates & times from Excel .xlsx files into Pandas!
Tuning Machine Learning Hyperparameters with Binary Search

8: Tuning Machine Learning Hyperparameters with Binary Search

Tune the n_estimators parameter in for a Random Forests classifier in scikit-learn in Python.
Tuning Random  Forests Hyperparameters with Binary Search Part II: max_depth

9: Tuning Random Forests Hyperparameters with Binary Search Part II: max_depth

Tune the max_depth parameter in for a Random Forests classifier in scikit-learn in Python
Tuning Random Forests Hyperparameters with Binary Search Part III: min_samples_leaf

10: Tuning Random Forests Hyperparameters with Binary Search Part III: min_samples_leaf

Tune the min_samples_leaf parameter in for a Random Forests classifier in scikit-learn in Python .
Using Random Forests for Feature Selection with Categorical Features

11: Using Random Forests for Feature Selection with Categorical Features

Python helper functions for adding feature importance, and displaying them as a single variable.
Downcast Numerical Data Types with Pandas

12: Downcast Numerical Data Types with Pandas

Using an Example Where We Downcast Numerical Columns.
Removing Duplicate Columns in Pandas

13: Removing Duplicate Columns in Pandas

Dealing with duplicate column names in your Pandas DataFrame.
Recasting Low-Cardinality Columns as Categoricals

14: Recasting Low-Cardinality Columns as Categoricals

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

15: Splitting Columns With Pandas

Split columns containing multiple values in your Pandas DataFrame into multiple columns, each containing a single value.
Being REALLY Lazy With Multiple Aggregations in Pandas

16: Being REALLY Lazy With Multiple Aggregations in Pandas

Perform multiple aggregate functions simultaneously with Pandas 0.25