-
Notifications
You must be signed in to change notification settings - Fork 700
Pygwalker Tools ‐ Metrics Template
Douding edited this page Jan 2, 2024
·
1 revision
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
- 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']
streamlit demo: https://pygwalker-metrics-demo.streamlit.app/