nirum / tableprint

Pretty console printing :clipboard: of tabular data in python :snake:
https://tableprint.readthedocs.io/
MIT License
174 stars 16 forks source link

str(array) is not stable for table print #12

Closed wooheaven closed 6 years ago

wooheaven commented 6 years ago
967757  2   30  14  100.00  1   [100.00]    [30, 14]
967722  2   14  6   100.00  2   [100.00, 100.00]    [30, 14, 6]
967699  2   6   2   100.00  3   [100.00, 100.00, 100.00]    [30, 14, 6, 2]
967686  2   2   0   100.00  4   [100.00, 100.00, 100.00, 100.00]    [30, 14, 6, 2, 0]
╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
│  policy_id  │  iteration  │     id      │   next_id   │ proability  │   length    │ proability_path │   id_path   │
├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
│      967757 │           2 │          30 │          14 │      100.00 │           1 │ [100.00]                         │ [30, 14]          │
│      967722 │           2 │          14 │           6 │      100.00 │           2 │ [100.00, 100.00]                 │ [30, 14, 6]       │
│      967699 │           2 │           6 │           2 │      100.00 │           3 │ [100.00, 100.00, 100.00]         │ [30, 14, 6, 2]    │
│      967686 │           2 │           2 │           0 │      100.00 │           4 │ [100.00, 100.00, 100.00, 100.00] │ [30, 14, 6, 2, 0] │
╰─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────╯
nirum commented 6 years ago

The issue here is that the width of the table is too small for the data. By default, the width parameter is 11. But some of your columns of data (e.g. the array [100.00, ...]) are much longer, which is why the table gets messed up.

Does it look reasonable if you pass in a larger width?

nirum commented 6 years ago

Going to close this as this is intended behavior.