Data-Analysis-Workflow
Building a Data Analysis Workflow with Colight
When working with data, you often need to explore, transform, and visualize it in various ways. Colight provides a seamless workflow that combines data manipulation with interactive visualization. Let's walk through a real-world example.
Loading and Exploring Data
For this example, we'll simulate some time-series data representing daily website traffic with seasonal patterns:
Generate dates for one year
Simulate traffic with weekly and seasonal patterns
Add weekly variations
Let's visualize the raw data:
Plot.line(
{"x": dates, "y": daily_traffic},
{"stroke": "steelblue", "strokeWidth": 1, "opacity": 0.7},
) + {"title": "Daily Website Traffic (2023)", "xlabel": "Date", "ylabel": "Visitors"}
Identifying Patterns
The raw data is noisy. Let's add a moving average to see the underlying trend:
Calculate 7-day moving average
Visualize both raw and smoothed data
traffic_plot
Interactive Analysis
Let's add controls to explore different time windows:
Create a plot that updates based on the slider
interactive_analysis | window_slider
Analyzing Weekly Patterns
Let's aggregate by day of week to see if there are consistent patterns:
Group by day of week
Calculate averages
Create a bar chart
Plot.barY(avg_by_weekday, {"x": 0, "y": 1, "fill": "steelblue"}) + {
"title": "Average Traffic by Day of Week",
"xlabel": "Day",
"ylabel": "Average Visitors",
}
Monthly Trends
Finally, let's look at monthly aggregations to see seasonal patterns:
Group by month
Calculate monthly averages
Create a line chart for monthly trends
Plot.line(
monthly_avg,
{"x": 0, "y": 1, "stroke": "darkgreen", "strokeWidth": 2, "marker": True},
) + {"title": "Monthly Traffic Trends", "xlabel": "Month", "ylabel": "Average Visitors"}