python

python
import mlflow
import mlflow.sklearn
from sklearn.metrics import roc_auc_score

mlflow.set_experiment('customer-churn')

Experiment tracking and model registry workflows with MLflow

mlflow experiment-tracking model-registry
by Dr. Elena Vasquez 1 tab
python
import psycopg

with psycopg.connect(conninfo) as connection:
    with connection.cursor() as cursor:
        cursor.execute(
            'SELECT id, email FROM users WHERE email = %s',

Parameterized queries in Python with psycopg

python sql-injection psycopg
by Kai Nakamura 1 tab
python
import pandas as pd

df = pd.read_csv('customers.csv')

df.columns = df.columns.str.strip().str.lower().str.replace(' ', '_', regex=False)

Cleaning missing values and normalizing messy CSV exports

pandas data-cleaning missing-values
by Dr. Elena Vasquez 1 tab
python
import pandas as pd

df = pd.read_csv('traffic.csv', parse_dates=['timestamp'])
df['timestamp'] = pd.to_datetime(df['timestamp'], utc=True)
df = df.set_index('timestamp').sort_index()

Time series resampling and rolling windows in pandas

pandas time-series resampling
by Dr. Elena Vasquez 1 tab
python
import logging
import time

logger = logging.getLogger(__name__)

Django middleware for request logging and timing

django python middleware
by Priya Sharma 1 tab
python
INSTALLED_APPS += [
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.google',

Django allauth for social authentication

django python authentication
by Priya Sharma 2 tabs
python
from django.db import models
from django.utils import timezone


class PostQuerySet(models.QuerySet):
    def published(self):

Django model managers for custom querysets

django python models
by Priya Sharma 1 tab
python
import torch.nn as nn

class SmallCNN(nn.Module):
    def __init__(self, num_classes: int) -> None:
        super().__init__()
        self.features = nn.Sequential(

Convolutional neural networks for image classification in PyTorch

pytorch cnn computer-vision
by Dr. Elena Vasquez 1 tab
python
from django.db import connection
from blog.models import Post


def get_top_authors(limit=10):
    """Get authors with most published posts using raw SQL."""

Django raw SQL queries for complex operations

django python database
by Priya Sharma 1 tab
python
from django.db.models import F, Window
from django.db.models.functions import RowNumber, Rank, DenseRank
from products.models import Sale


def get_sales_with_ranking():

Django ORM window functions for analytics

django python database
by Priya Sharma 1 tab
python
from django.contrib.auth.models import AbstractUser
from django.db import models


class CustomUser(AbstractUser):
    """Extended user model with additional fields."""

Django custom user model best practices

django python models
by Priya Sharma 2 tabs
python
from defusedxml.ElementTree import fromstring

payload = request.data.decode('utf-8')
root = fromstring(payload)
invoice_number = root.findtext('invoice_number')

XXE safe XML parsing with external entity resolution disabled

xxe xml parsing
by Kai Nakamura 1 tab