Displaying unitful dataframes

rafael.guerra
Wed, 06 Oct 2021 19:47:15 +0000
General Usage

What is the recommended procedure for displaying Unitful Dataframes?
Example:

using DataFrames, Unitful
d = (0:10:1000)u"m"
v = 1500u"m/s" .+ 1.5u"1/s"*d
t = [0u"s"; cumsum(diff(d) ./ v[1:end-1])]
df = DataFrame(depth=d, velocity=v, time=t)

df displays like this:

 Row │ depth      velocity       time
     │ Quantity…  Quantity…      Quantity…
─────┼────────────────────────────────────────
   1 │       0 m  1500.0 m s^-1         0.0 s
   2 │      10 m  1515.0 m s^-1  0.00666667 s
   3 │      20 m  1530.0 m s^-1   0.0132673 s
  ⋮  │     ⋮            ⋮             ⋮
  99 │     980 m  2970.0 m s^-1    0.457052 s
 100 │     990 m  2985.0 m s^-1    0.460419 s
 101 │    1000 m  3000.0 m s^-1    0.463769 s

Ideally, the units should appear clearly and only below the column names. Thank you.

4 posts - 2 participants