Popular Days of the Week for Book Checkouts
MAT 259, 2015
Brock Noah
Concept
I wanted to get a general sense of popular days to checkout books. The true number of checkouts per day doesn't matter, but the number of checkouts relative to another day is the deciding factor.
Query
SELECT
sum(CASE WHEN weekday(cout) = 1 THEN 1 ELSE 0 END) as Sunday,
sum(CASE WHEN weekday(cout) = 2 THEN 1 ELSE 0 END) as Monday,
sum(CASE WHEN weekday(cout) = 3 THEN 1 ELSE 0 END) as Tuesday,
sum(CASE WHEN weekday(cout) = 4 THEN 1 ELSE 0 END) as Wednesday,
sum(CASE WHEN weekday(cout) = 5 THEN 1 ELSE 0 END) as Thursday,
sum(CASE WHEN weekday(cout) = 6 THEN 1 ELSE 0 END) as Friday,
sum(CASE WHEN weekday(cout) = 7 THEN 1 ELSE 0 END) as Saturday
FROM spl2.inraw
WHERE year(cout) ="2010"
AND itemtype LIKE "%bk"
AND deweyClass is not null
group BY floor(deweyClass/10)*10
Process
The year was set to 2010 to minify the query time (SUM CASE statements can be costly), but the search was open to juvenile, young adult and adult books. Finished at 265 seconds.
I count the number of checkouts per day, then sort an array of weekdays that belongs to a dewey grouping of 10. The sorted low to high array allows me to rank the most popular day by determining the index position of a certain week day. This value will determine the opacity for the weekday. Each dewey grouping consists of the same colors, and the same increment of opac value. The darker colors represent more checkouts and lighter colors represent less checkouts.
Final result
A quick look at the visualization can tell you the most and least popular days to checkout books based on the darkness of a weekday. Most popular days seems to be Monday and Friday with least popular days Thursday and Saturday.
Code