File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ instance Show DataFrame where
105105asText :: DataFrame -> T. Text
106106asText d =
107107 let header = " index" : map fst (sortBy (compare `on` snd ) $ M. toList (columnIndices d))
108+ types = V. toList $ V. filter (/= " " ) $ V. map getType (columns d)
109+ getType Nothing = " "
110+ getType (Just (BoxedColumn (column :: Vector a ))) = T. pack $ show (Type.Reflection. typeRep @ a )
111+ getType (Just (UnboxedColumn (column :: VU. Vector a ))) = T. pack $ show (Type.Reflection. typeRep @ a )
108112 -- Separate out cases dynamically so we don't end up making round trip string
109113 -- copies.
110114 get (Just (BoxedColumn (column :: Vector a ))) =
@@ -123,7 +127,7 @@ asText d =
123127 rows =
124128 transpose $
125129 zipWith (curry (V. toList . getTextColumnFromFrame d)) [0 .. ] header
126- in showTable header rows
130+ in showTable header ( " Int " : types) rows
127131
128132metadata :: DataFrame -> String
129133metadata df = show (columnIndices df) ++ " \n " ++
Original file line number Diff line number Diff line change @@ -63,13 +63,14 @@ right = fillRight ' '
6363center :: Int -> T. Text -> T. Text
6464center = fillCenter ' '
6565
66- showTable :: [T. Text ] -> [[T. Text ]] -> T. Text
67- showTable header rows =
66+ showTable :: [T. Text ] -> [T. Text ] -> [ [T. Text ]] -> T. Text
67+ showTable header types rows =
6868 let cs = map (\ h -> ColDesc center h left) header
69- widths = [maximum $ map T. length col | col <- transpose $ header : rows]
69+ widths = [maximum $ map T. length col | col <- transpose $ header : types : rows]
70+ border = T. intercalate " ---" [T. replicate width (T. singleton ' -' ) | width <- widths]
7071 separator = T. intercalate " -|-" [T. replicate width (T. singleton ' -' ) | width <- widths]
7172 fillCols fill cols = T. intercalate " | " [fill c width col | (c, width, col) <- zip3 cs widths cols]
72- in T. unlines $ fillCols colTitleFill header : separator : map (fillCols colValueFill) rows
73+ in T. unlines $ border : fillCols colTitleFill header : separator : fillCols colTitleFill types : separator : map (fillCols colValueFill) rows
7374
7475headOr :: a -> [a ] -> a
7576headOr v [] = v
You can’t perform that action at this time.
0 commit comments