Skip to content

Commit 5c58485

Browse files
committed
Commit some changes
- Added hero image at the top - Some changes to intro that emphasize relaunch
1 parent 59202d1 commit 5c58485

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

src/time_series/tablecloth_time.clj renamed to src/ezmiller/relaunching_tablecloth_time.clj

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
^{:kindly/hide-code true
2-
:clay {:title "Getting Started with tablecloth.time"
2+
:clay {:title "Relaunch tablecloth.time: Composability over Abstraction"
33
:quarto {:author [:ezmiller]
44
:description "A composable approach to time series analysis in Clojure"
55
:draft false
66
:type :post
77
:date "2026-03-27"
88
:category :clojure
99
:tags [:time-series :tablecloth :data-science]}}}
10-
(ns time-series.tablecloth-time
10+
(ns ezmiller.relaunching-tablecloth-time
1111
(:require [tablecloth.api :as tc]
1212
[tablecloth.time.api :as tct]
1313
[scicloj.tableplot.v1.plotly :as plotly]
1414
[tech.v3.datatype.functional :as dfn]
1515
[scicloj.kindly.v4.kind :as kind]))
1616

17-
;; [tablecloth.time](https://github.com/scicloj/tablecloth.time) is a composable
17+
^{:kindly/hide-code true}
18+
(kind/html "<figure>
19+
<img src=\"vic_elec_yearly.png\" alt=\"Victoria electricity demand by day of year, colored by year\" style=\"width:100%\"/>
20+
<figcaption>Half-hourly electricity demand in Victoria, Australia (2012–2014). Each line is one day, phased over the time of day (0 = midnight, 1 = midnight). Colors indicate year.</figcaption>
21+
</figure>")
22+
23+
;; I recently relaunched an old Scicloj project called [tablecloth.time](https://github.com/scicloj/tablecloth.time). The goal of this project was to build a composable
1824
;; extension for time series analysis built on top of
19-
;; [tablecloth](https://scicloj.github.io/tablecloth/). This post walks through
20-
;; its core primitives using the classic Victoria electricity demand dataset.
25+
;; [tablecloth](https://scicloj.github.io/tablecloth/). Originally, we
26+
;; had built this project around a dataset index mechanism that was
27+
;; built into tech.ml.dataset, but after that feature was removed in
28+
;; v7, the project required a rethink. This post walks through that
29+
;; rethink and the projects core core primitives today using the
30+
;; Victoria electricity demand dataset.
2131

2232
;; ## Design Philosophy
2333
;;
@@ -42,9 +52,9 @@
4252
;; Australia, spanning 2012-2014. Let's load it and take a look.
4353

4454
(def vic-elec
45-
(-> (tc/dataset "https://raw.githubusercontent.com/scicloj/tablecloth.time/main/data/vic_elec.csv"
55+
(-> (tc/dataset "https://gist.githubusercontent.com/ezmiller/6edf3e0f41848f532436c15bc94c2f4d/raw/vic_elec.csv"
4656
{:key-fn keyword})
47-
(tc/convert-types :Time :instant)))
57+
(tc/convert-types :Time :local-date-time)))
4858

4959
(tc/head vic-elec)
5060

@@ -110,7 +120,7 @@
110120
(-> vic-elec
111121
(tct/add-lag :Demand 48 :Demand_lag48)
112122
(tc/drop-missing)
113-
(plotly/layer-point {:=x :Demand_lag48
123+
(plotly/layer-point {:=x :Demand_lag48
114124
:=y :Demand
115125
:=mark-opacity 0.3}))
116126

@@ -123,14 +133,14 @@
123133
;; is a composable pattern: extract the time component you want, group by it,
124134
;; and aggregate.
125135
;;
126-
;; Daily averages:
136+
;; Daily averages (grouping by year, month, and day):
127137

128138
(-> vic-elec
129-
(tct/add-time-columns :Time [:date])
130-
(tc/group-by [:date])
139+
(tct/add-time-columns :Time [:year :month :day])
140+
(tc/group-by [:year :month :day])
131141
(tc/aggregate {:Demand #(dfn/mean (:Demand %))
132142
:Temperature #(dfn/mean (:Temperature %))})
133-
(tc/order-by [:date])
143+
(tc/order-by [:year :month :day])
134144
(tc/head 10))
135145

136146
;; Monthly averages:
@@ -155,8 +165,8 @@
155165
(tc/group-by [:weekend? :hour])
156166
(tc/aggregate {:Demand #(dfn/mean (:Demand %))})
157167
(tc/order-by [:hour])
158-
(plotly/layer-line {:=x :hour
159-
:=y :Demand
168+
(plotly/layer-line {:=x :hour
169+
:=y :Demand
160170
:=color :weekend?}))
161171

162172
;; Weekday demand shows the classic two-peak pattern (morning and evening),

0 commit comments

Comments
 (0)