Skip to content
Other Pygwalker Tools
Pygwalker Tools ‐ Metrics Template

Pygwalker Tools ‐ Metrics Template

About Metrics Template

Explore additional feature development within Pygwalker, such as the introduction of metric templates.

This will save users the process of writing sql to calculate metrics, currently still in POC stage, example:

# Charts of retained the next day and daily new users
# Chart components base on the altair
 
from pygwalker.data_parsers.database_parser import Connector
from pygwalker_tools.metrics import MetricsChart
 
dataset = Connector(
    "snowflake://user_name:passowrd@host/database",
    """SELECT * FROM xxx"""
)
 
# or a dataframe
# dataset = pd.read_csv("xxx.csv")
 
retention = MetricsChart(
    dataset,
    {"date": "your_date_field", "user_id": "your_user_id_field", "user_signup_date": "your_xxx_field"},
    params={"time_unit": "day", "time_size": 1}
).retention()
 
new_user_count = MetricsChart(dataset, {"date": "your_date_field", "user_id": "your_user_id_field", "user_signup_date": "your_xxx_field"}).new_user_count().properties(height=60)
 
retention & new_user_count

Available Metrics

  • pv: Page Views
    • fields: ['date']
    • dimensions: ['date']
    • params: []
  • uv: User Views
    • fields: ['date', 'user_id']
    • dimensions: ['date']
    • params: []
  • mau: Monthly Active Users
    • fields: ['date', 'user_id']
    • dimensions: ['date']
    • params: []
  • retention: Retention
    • fields: ['date', 'user_id', 'user_signup_date']
    • dimensions: ['date']
    • params: ['time_unit', 'time_size']
  • new_user_count: New User Count
    • fields: ['date', 'user_id', 'user_signup_date']
    • dimensions: ['date']
    • params: []
  • cohort_matrix: Cohort Matrix
    • fields: ['date', 'user_id', 'user_signup_date']
    • dimensions: ['date', 'time_size']
    • params: []
  • active_user_count: Active User Count
    • fields: ['date', 'user_id']
    • dimensions: ['date']
    • params: ['within_active_days']
  • user_churn_rate_base_active: User Churn Rate Base Active
    • fields: ['date', 'user_id']
    • dimensions: ['date']
    • params: ['within_active_days']

Online Demo:

streamlit demo: https://pygwalker-metrics-demo.streamlit.app/ (opens in a new tab)