One Million Digits of Pi
Just a bit late for Pi Day, this dataset is the first million digits of pi. (Actually, it’s the first 1,000,001 digits—I feel like whoever put it together couldn’t decide whether to count 1 million digits or a million decimal places—so they included both.)
Anyway, the visual I landed on is primarily based on just the first hundred digits, but I did include a count of occurrences over the first million as the size parameter. It’s a little experimental, but it seemed more interesting than just the number of occurrences in a bar chart.
The Query
The source pi_digits.csv was just two columns, showing the position and digit:
| digit_position | digit |
|---|---|
| 1 | 3 |
| 2 | 1 |
| 3 | 4 |
| 4 | 1 |
| 5 | 5 |
| 6 | 9 |
| 7 | 2 |
| 8 | 6 |
| 9 | 5 |
| 10 | 3 |
| • | • |
| • | • |
| • | • |
| 999999 | 1 |
| 1000000 | 5 |
| 1000001 | 1 |
Since I was counting occurrences over the full dataset, I did that in a CTE and then joined it to the first 100 rows from the original table:
with occurrences as (
from pi_digits
select digit,
count(*) as occurrences
group by all
)
from pi_digits
join occurrences
using (digit)
order by digit_position
limit 100