get_value_counts
Analyze frequency distribution of values in a column to understand categorical data patterns, identify common values, and assess data quality with configurable counts or percentages.
Instructions
Get frequency distribution of values in a column.
Analyzes the distribution of values in a specified column, providing counts and optionally percentages for each unique value. Essential for understanding categorical data and identifying common patterns.
Returns: Frequency distribution with counts/percentages for each unique value
Analysis Features: 🔢 Frequency Counts: Raw counts for each unique value 📊 Percentage Mode: Normalized frequencies as percentages 🎯 Top Values: Configurable limit for most frequent values 📈 Summary Stats: Total values, unique count, distribution insights
Examples: # Basic value counts counts = await get_value_counts(ctx, "category")
# Get percentages for top 10 values
counts = await get_value_counts(ctx, "status",
normalize=True, top_n=10)
# Sort in ascending order
counts = await get_value_counts(ctx, "grade", ascending=True)AI Workflow Integration: 1. Categorical data analysis and encoding decisions 2. Data quality assessment (identifying rare values) 3. Understanding distribution for sampling strategies 4. Feature engineering insights for categorical variables
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| column | Yes | Name of the column to analyze value distribution | |
| normalize | Yes | Return percentages instead of raw counts | |
| sort | Yes | Sort results by frequency | |
| ascending | Yes | Sort in ascending order (False = descending) | |
| top_n | Yes | Maximum number of values to return (None = all values) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| column | Yes | Name of the analyzed column | |
| success | No | Whether operation completed successfully | |
| normalize | No | Whether counts are normalized as proportions | |
| total_values | Yes | Total number of values (including duplicates) | |
| value_counts | Yes | Count or proportion of each unique value | |
| unique_values | Yes | Number of unique/distinct values |