Show for 2-indexed Expressions / MatrixTables

cc: @jigold, @tpoterba, @wang

Consider mt:

Row-Indexed:
  b: tfloat64
  b2: tfloat64
  b3: tboolean
Col-Indexed:
  a: tint32
  a2: tint32
  a3: tboolean
Row- and Col-Indexed:
  c: tint32
  d: tfloat64
Row Keys: [a, a2]
Col Keys: [b, b2]
In[0]: mt.show()
Out[0]:
Rows:
+--------+--------+---------+
| a      | a2     | a3      |
+--------+--------+---------+
| tint32 | tint32 | boolean |
+--------+--------+---------+
|      3 |      3 |    True |
|      5 |      5 |   False |
|  ...   |  ...   |    ...  |
+--------+--------+---------+
Cols:
+----------+----------+---------+
| b        | b2       | b3      |
+----------+----------+---------+
| tfloat64 | tfloat64 | boolean |
+----------+----------+---------+
|      3.0 |      3.0 |   False |
|      5.0 |      5.0 |   False |
|   ...    |   ...    |    ...  |
+----------+----------+---------+
Entries:
                      +----+---------------+----------------+----
                      | a  |             1 |              5 | ...
+----------+----------+----+---------------+----------------+----
| b        | b2       | a2 |             3 |             10 | ...
+----------+----------+----+---------------+----------------+----
|      3.0 |     10.0 |    | {c:3, d:5.2} | {c:21, d:0.1} | ...
|      5.0 |     -1.0 |    | {c:3, d:5.2} | {c:21, d:0.1} | ...
|  ...     |  ...     |    |       ...     |      ...       | ...
+----------+----------+    +---------------+----------------+

In this representation we can show a lot more rows than columns on a typical
computer screen.

I think this representation is even nicer when the entries are primitives rather
than compound data:

                      +----+-----+-----+-----+-----+----
                      | a  |   1 |   5 |   5 |   6 | ...
+----------+----------+----+-----+-----+-----+-----+----
| b        | b2       | a2 |   3 |  10 |  12 |   1 | ...
+----------+----------+----+-----+-----+-----+-----+----
|      3.0 |     10.0 |    | 0/0 | 1/0 | 1/0 | 1/0 | ...
|      5.0 |     -1.0 |    | 0/0 | 1/0 | 1/0 | 1/0 | ...
|  ...     |  ...     |    | ... | ... | ... | ... | ...
+----------+----------+    +-----+-----+-----+-----+----

edit: fixed transposition of table
edit: fix keys

I like it except for two things:

  • I think your cols and rows are switched for the entries.
  • What happens if there are more than 2 rows or cols. How will you truncate them in the entries picture?

I also wish there was some space between the components in the entries table.

Ah yes, I screwed up my example, I wanted to only print the keys. I will fix.

Another option for the entries is

Entries:
                      +----+---------+-----------+----
                      | a  |       1 |         5 | ...
                      +----+---------+-----------+----
                      | a2 |       3 |        10 | ...
+----------+----------+----+---+-----+-----------+----
| b        | b2       |    | c |   d |   c |   d | ...
+----------+----------+    +---+-----+-----------+----
|      3.0 |     10.0 |    | 3 | 5.2 |  21 | 0.1 | ...
|      5.0 |     -1.0 |    | 3 | 5.2 |  21 | 0.1 | ...
|  ...     |  ...     |    |...| ... | ... | ... | ...
+----------+----------+----+---------+----------------+

I like that last version. It seems like there’s a clearer separation between the headers for the row keys and column keys (in the first one the row key headers kind of lead straight into the last column key row). How would you feel about getting rid of the delimiter between entry fields? Something like

Entries:
                      +----+---------+-----------+----
                      | a  |       1 |         5 | ...
                      +----+---------+-----------+----
                      | a2 |       3 |        10 | ...
+----------+----------+----+---+-----+-----------+----
| b        | b2       |    | c     d |   c     d | ...
+----------+----------+    +---------+-----------+----
|      3.0 |     10.0 |    | 3   5.2 |  21   0.1 | ...
|      5.0 |     -1.0 |    | 3   5.2 |  21   0.1 | ...
|  ...     |  ...     |    |...  ... |  ...  ... | ...
+----------+----------+----+---------+-----------+----

I like this. I also considered a fully delimiter less set up, which is basically the opposite of the readMatrixTable stuff.