python
14 lines · 1 tab
Dr. Elena Vasquez
Apr 2026
1 tab
import great_expectations as gx
context = gx.get_context()
data_source = context.data_sources.add_pandas(name='training_data')
asset = data_source.add_dataframe_asset(name='churn_asset')
batch_definition = asset.add_batch_definition_whole_dataframe('full_dataframe')
batch = batch_definition.get_batch(batch_parameters={'dataframe': df})
suite = context.suites.add(gx.ExpectationSuite(name='churn_training_suite'))
batch.expect_column_values_to_not_be_null('customer_id')
batch.expect_column_values_to_be_between('age', min_value=18, max_value=100)
batch.expect_column_distinct_values_to_be_in_set('churned', [0, 1])
batch.expect_column_proportion_of_unique_values_to_be_between('customer_id', min_value=1.0, max_value=1.0)
1 file · python
Explain with highlit
Before retraining, I want hard guarantees that the data feed still looks structurally sane. Great Expectations gives teams a shared validation language that analysts, ML engineers, and data engineers can all inspect. I use it to codify invariants that should never silently drift.
Related snips
ruby
class SignupForm
include ActiveModel::Model
include ActiveModel::Attributes
attribute :account_name, :string
attribute :email, :string
Shallow Controller, Deep Params: Form Object Pattern
rails
activemodel
form-object
by codesnips
3 tabs
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Validation Example</title>
<style>
HTML forms with validation and accessibility
html
forms
validation
by Alex Chang
1 tab
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
typescript
import axios from 'axios';
export type NormalizedErrors = {
fields: Record<string, string>;
formLevel: string | null;
};
Frontend: normalize and display server validation errors
ux
typescript
react
by codesnips
3 tabs
php
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
Laravel form requests for validation
laravel
validation
form-requests
by Carlos Mendez
2 tabs
ruby
class SubscriptionsController < ApplicationController
def new
@subscription = current_account.subscriptions.new
end
def create
Turbo Streams: append server-side validation warnings
rails
turbo
hotwire
by codesnips
4 tabs
Share this code
Here's the card — post it anywhere.