Skip to content

Commit

Permalink
tablecloth_table_processing - simplified table views a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
daslu committed Jan 17, 2025
1 parent 336912d commit a86e1b6
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions notebooks/noj_book/tablecloth_table_processing.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

;; author: Daniel Slutsky

;; last change: 2024-12-08

;; last change: 2025-01-17

;; [Tablecloth](https://scicloj.github.io/tablecloth/)
;; is a table processing library
Expand Down Expand Up @@ -42,7 +41,7 @@

;; ## About this tutorial

;; In this tutorial, we will demonstrate the ergonomics of so-called dataset
;; In this tutorial, we will demonstrate the ergonomics of so-called *dataset*
;; data strucures provided by Tablecloth. Datasets are table-like data structures,
;; often called data-frames in other data science platforms.

Expand Down Expand Up @@ -174,16 +173,6 @@ some-trips
:background "floralwhite"}}
some-trips])

;; For use in this tutorial, let us define our own customized view:

(defn compact-view [dataset]
(kind/hiccup
[:div {:style {:max-width "100%"
:max-height "400px"
:overflow-x :auto
:overflow-y :auto}}
dataset]))

;; ## What is a dataset?

;; Let us explore this data structure, our little dataset of bike trips.
Expand Down Expand Up @@ -309,9 +298,7 @@ some-trips

;; We can use the `tc/info` function to summarize a dataset:

(-> some-trips
tc/info
compact-view)
(tc/info some-trips)

;; ## Reading datasets

Expand All @@ -325,8 +312,7 @@ some-trips
;; First, let us read just a few rows:

(-> "data/chicago-bikes/202304_divvy_tripdata.csv.gz"
(tc/dataset {:num-rows 3})
compact-view)
(tc/dataset {:num-rows 3}))

;; So reading a dataset is easy, but sometimes we may wish to pass a few options
;; to handle it a bit better.
Expand Down Expand Up @@ -393,12 +379,9 @@ some-trips
keyword))
:parser-fn {"started_at" datetime-parser
"ended_at" datetime-parser}})))
(compact-view
trips)
trips

(-> trips
tc/info
compact-view)
(tc/info trips)

;; It is a whole month of bike trips!

Expand Down Expand Up @@ -431,9 +414,7 @@ some-trips

;; The first few trips:

(-> trips
tc/head
compact-view)
(tc/head trips)

;; Just a few columns:
(-> trips
Expand Down

0 comments on commit a86e1b6

Please sign in to comment.