@@ -2263,21 +2263,22 @@ DataFrame >> toColumnsAt: arrayOfColumnNumbers applyElementwise: aBlock [
22632263DataFrame >> toMarkdown [
22642264 " Prints the DataFrame as a Markdown formatted table"
22652265
2266- | markdown columnWidths |
2267- self addColumn: self rowNames named: ' #' atPosition: 1 .
2266+ | markdown columnWidths dataFrame |
2267+ dataFrame := self copy.
2268+ dataFrame addColumn: dataFrame rowNames named: ' #' atPosition: 1 .
22682269 markdown := WriteStream on: String new .
22692270 markdown nextPutAll: ' | ' .
22702271
2271- columnWidths := self columnNames collect: [ :columnName |
2272+ columnWidths := dataFrame columnNames collect: [ :columnName |
22722273 | maxWidth |
22732274 maxWidth := columnName size.
2274- self rows do: [ :row |
2275+ dataFrame rows do: [ :row |
22752276 | value |
22762277 value := row at: columnName.
22772278 maxWidth := maxWidth max: value printString size ].
22782279 maxWidth ].
22792280
2280- self columnNames withIndexDo: [ :columnName :index |
2281+ dataFrame columnNames withIndexDo: [ :columnName :index |
22812282 | paddedColumnName |
22822283 paddedColumnName := columnName padRightTo: (columnWidths at: index).
22832284 markdown nextPutAll: paddedColumnName , ' | ' ].
@@ -2292,7 +2293,7 @@ DataFrame >> toMarkdown [
22922293
22932294 markdown cr.
22942295
2295- self asArrayOfRows do: [ :row |
2296+ dataFrame asArrayOfRows do: [ :row |
22962297 markdown nextPutAll: ' | ' .
22972298 row withIndexDo: [ :value :index |
22982299 | paddedValue |
0 commit comments