Skip to content

non-numerical dataframesยค

dataframes will be challenging for folks with dyscalculia. the wai-adapt has started writing guidance for concepts like this, but dataframes are likely out of scope.

this notebook sketches an approach towards subtle visual identificaition of a table value in a distribution. before making this i realized that there is no way to explore a table of numbers with dyscalculia. i imagine i'll be thinking more about the visual, audible, and tactile aspects of numeric information.

we'll want a systematic approach where we explore how the dimensions of line, tone/weight, and, lastly, color can present numerical concepts using visual gestalts.

an interesting outcome of this approach is that scrolling activates an animation of the values. it reverses back into albers assertion that notice color in motion and when it is changing. simple concepts like this have significant potential for activiting ones participation in exploring data.

%%
        df = pipe(numpy.linspace(0, 360, 101), pandas.Index).rename("index").to_series().mul(numpy.pi/180).apply(lambda x: pandas.Series(dict(x=numpy.cos(x), y=numpy.sin(x))))
        style_attributes = lambda extra="": compose_left(operator.methodcaller("items"), map(F"--%s{extra}: %s".__mod__), ";".join, "{};".format)

{% set df = df.reset_index() %}
{% set summary = df.describe() %}
{% set groups = [df, df.sample(20)] %}
<style>
.dataframe {
    --height: 600px;
    display: block;
    position: relative;
    width: 100%;
    border: 5px red solid;
    {%- for col in df.columns -%}
    --d{{col}}: calc(var(--{{col}}-max) - var(--{{col}}-min));
    {%- endfor -%}
    --dx: calc(var(--x-max) - var(--x-min));
    --dy: calc(var(--y-max) - var(--y-min));
    tbody, thead {
        tr {
            border: 4px white solid;
            position: relative;
            td {
                {%- for col in df.columns -%}
                &:nth-of-type({{loop.index}}) {
                    --rel: calc((var(--{{col}}) - var(--{{col}}-min)) / var(--d{{col}}));
                }
                {%- endfor -%}
                background: linear-gradient(90deg, 
                        rgba(0,0,0,0) calc(100% * var(--rel) - .25rem), 
                        rgba(128,128,128,.5) calc(100% * var(--rel)), 
                        rgba(0,0,0,0) calc(100% * var(--rel) + .25rem)
                    );
            }

        }
    }
}

</style>

%%
<table class="dataframe" min"].pipe(style_attributes("-min"))}}{{summary.loc["max"].pipe(style_attributes("-max"))}}"="" style="{{summary.loc[">
<caption>a table of sin and cosine data with visual representations in each cell.</caption>
<thead>
<tr>
<th>index</th>
         {%- for k in df.columns -%}
             <th>{{k}}</th>
         {%- endfor -%}
    </tr>
    {%-for i, row in summary.iterrows() -%}
    <tr style="{{style_attributes()(row)}}">
<th scope="row">{{row.name}}</th>
        {%- for k in df.columns -%}
        <td>{{row.loc[k]}}</td>
        {%- endfor -%}
    </tr>
    {%- endfor -%}
    </thead>
     {%- for g in groups -%}
     <tbody>
         {%- for i, row in g.iterrows() -%}
            <tr style="{{style_attributes()(row)}}">
<th>{{loop.index}}</th>
             {%- for k in df.columns -%}
                 <td>{{row.loc[k]}}</td>
             {%- endfor -%}
            </tr>
         {%- endfor -%}
     </tbody>
     {%- endfor -%}
</table>
    df = pipe(numpy.linspace(0, 360, 101), pandas.Index).rename("index").to_series().mul(numpy.pi/180).apply(lambda x: pandas.Series(dict(x=numpy.cos(x), y=numpy.sin(x))))
    style_attributes = lambda extra="": compose_left(operator.methodcaller("items"), map(F"--%s{extra}: %s".__mod__), ";".join, "{};".format)

%%

a table of sin and cosine data with visual representations in each cell.
indexindexxy
count101.0101.0101.0
mean180.00.0099009900990099275.681783374570121e-18
std105.480614332682010.71407351869328550.7071067811865475
min0.0-1.0-1.0
25%90.0-0.6845471059286887-0.6845471059286887
50%180.06.123233995736766e-170.0
75%270.00.72896862742141160.6845471059286887
max360.01.01.0
10.01.00.0
23.60.99802672842827160.06279051952931337
37.20.99211470131447790.12533323356430426
410.80.98228725072868870.18738131458572463
514.40.96858316112863110.2486898871648548
618.00.95105651629515350.3090169943749474
721.60.92977648588825130.368124552684678
825.20.90482705246601960.42577929156507266
928.80.87630668004386360.4817536741017153
1032.40.84432792550201510.5358267949789967
1136.00.80901699437494750.5877852522924731
1239.60.77051324277578910.6374239897486897
1343.20.72896862742141160.6845471059286887
1446.8000000000000040.68454710592868860.7289686274214116
1550.40.63742398974868970.7705132427757893
1654.00.58778525229247310.8090169943749475
1757.60.53582679497899650.8443279255020151
1861.20.481753674101715160.8763066800438637
1964.80.425779291565072660.9048270524660196
2068.40.368124552684677860.9297764858882515
2172.00.309016994374947450.9510565162951535
2275.600000000000010.248689887164854740.9685831611286311
2379.20.187381314585724520.9822872507286887
2482.80.125333233564304260.9921147013144779
2586.40.06279051952931330.9980267284282716
2690.06.123233995736766e-171.0
2793.60000000000001-0.06279051952931340.9980267284282716
2897.2-0.125333233564304370.9921147013144778
29100.8-0.18738131458572460.9822872507286887
30104.4-0.248689887164854850.9685831611286311
31108.0-0.309016994374947340.9510565162951536
32111.60000000000001-0.3681245526846780.9297764858882513
33115.2-0.42577929156507270.9048270524660195
34118.8-0.481753674101715050.8763066800438637
35122.4-0.53582679497899690.844327925502015
36126.0-0.5877852522924730.8090169943749475
37129.6-0.63742398974868970.7705132427757893
38133.20000000000002-0.68454710592868870.7289686274214114
39136.8-0.72896862742141170.6845471059286885
40140.4-0.77051324277578940.6374239897486895
41144.0-0.80901699437494730.5877852522924732
42147.6-0.84432792550201510.5358267949789967
43151.20000000000002-0.87630668004386360.4817536741017152
44154.8-0.90482705246601960.4257792915650725
45158.4-0.92977648588825150.36812455268467775
46162.0-0.95105651629515350.3090169943749475
47165.6-0.96858316112863110.24868988716485482
48169.20000000000002-0.98228725072868870.18738131458572457
49172.8-0.99211470131447790.1253332335643041
50176.4-0.99802672842827160.06279051952931314
51180.0-1.01.2246467991473532e-16
52183.6-0.9980267284282716-0.06279051952931335
53187.20000000000002-0.9921147013144779-0.12533323356430429
54190.8-0.9822872507286886-0.18738131458572477
55194.4-0.9685831611286311-0.24868988716485502
56198.0-0.9510565162951536-0.3090169943749473
57201.6-0.9297764858882515-0.3681245526846779
58205.20000000000002-0.9048270524660195-0.42577929156507266
59208.8-0.8763066800438635-0.4817536741017154
60212.4-0.844327925502015-0.5358267949789968
61216.0-0.8090169943749476-0.587785252292473
62219.6-0.7705132427757893-0.6374239897486896
63223.20000000000002-0.7289686274214116-0.6845471059286887
64226.8-0.6845471059286886-0.7289686274214116
65230.4-0.6374239897486895-0.7705132427757894
66234.0-0.5877852522924732-0.8090169943749473
67237.6-0.5358267949789971-0.8443279255020149
68241.20000000000002-0.48175367410171527-0.8763066800438636
69244.8-0.42577929156507216-0.9048270524660198
70248.4-0.3681245526846778-0.9297764858882515
71252.0-0.30901699437494756-0.9510565162951535
72255.6-0.2486898871648553-0.968583161128631
73259.2-0.18738131458572463-0.9822872507286887
74262.8-0.12533323356430373-0.9921147013144779
75266.40000000000003-0.06279051952931321-0.9980267284282716
76270.0-1.8369701987210297e-16-1.0
77273.60.06279051952931372-0.9980267284282716
78277.20.12533323356430423-0.9921147013144779
79280.80.18738131458572513-0.9822872507286886
80284.400000000000030.24868988716485493-0.9685831611286311
81288.00.30901699437494723-0.9510565162951536
82291.60.36812455268467825-0.9297764858882512
83295.20.4257792915650726-0.9048270524660196
84298.80.4817536741017157-0.8763066800438634
85302.400000000000030.5358267949789968-0.844327925502015
86306.00.5877852522924729-0.8090169943749476
87309.60.63742398974869-0.770513242775789
88313.20.6845471059286886-0.7289686274214116
89316.80.7289686274214119-0.6845471059286883
90320.400000000000030.7705132427757894-0.6374239897486896
91324.00.8090169943749473-0.5877852522924734
92327.60.8443279255020153-0.5358267949789963
93331.20.8763066800438636-0.4817536741017153
94334.80.9048270524660197-0.4257792915650722
95338.400000000000030.9297764858882515-0.36812455268467786
96342.00.9510565162951535-0.3090169943749476
97345.60.9685831611286312-0.2486898871648545
98349.20.9822872507286887-0.18738131458572468
99352.80.9921147013144779-0.1253332335643038
100356.400000000000030.9980267284282716-0.06279051952931326
101360.01.0-2.4492935982947064e-16
1172.8-0.99211470131447790.1253332335643041
2356.400000000000030.9980267284282716-0.06279051952931326
3248.4-0.3681245526846778-0.9297764858882515
4140.4-0.77051324277578940.6374239897486895
5187.20000000000002-0.9921147013144779-0.12533323356430429
636.00.80901699437494750.5877852522924731
7320.400000000000030.7705132427757894-0.6374239897486896
872.00.309016994374947450.9510565162951535
964.80.425779291565072660.9048270524660196
10162.0-0.95105651629515350.3090169943749475
11219.6-0.7705132427757893-0.6374239897486896
12111.60000000000001-0.3681245526846780.9297764858882513
13133.20000000000002-0.68454710592868870.7289686274214114
1450.40.63742398974868970.7705132427757893
15226.8-0.6845471059286886-0.7289686274214116
16338.400000000000030.9297764858882515-0.36812455268467786
17115.2-0.42577929156507270.9048270524660195
18295.20.4257792915650726-0.9048270524660196
19201.6-0.9297764858882515-0.3681245526846779
20284.400000000000030.24868988716485493-0.9685831611286311