Skip to content

Commit d40016b

Browse files
authored
Merge pull request #268 from Joshua-Dias-Barreto/chainedSorting
Fixed #267. #asDataFrame now retains the collection elements data types.
2 parents 023a2a6 + 052482b commit d40016b

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/DataFrame-Tests/DataFrameTest.class.st

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,21 @@ DataFrameTest >> testAsDataFrame [
433433
self assert: actual equals: expected
434434
]
435435

436+
{ #category : #tests }
437+
DataFrameTest >> testAsDataFrameDataTypes [
438+
439+
| actual expected |
440+
actual := #( #( a 1 3.1 )
441+
#( b 2 6.5 )
442+
#( c 3 9.7 ) ) asDataFrame dataTypes.
443+
expected := Dictionary newFrom: {
444+
(1 -> Object).
445+
(2 -> SmallInteger).
446+
(3 -> SmallFloat64) }.
447+
448+
self assert: actual equals: expected
449+
]
450+
436451
{ #category : #tests }
437452
DataFrameTest >> testAsDataFrameEmpty [
438453

src/DataFrame/Collection.extension.st

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ Collection >> asDataFrame [
2323
| value |
2424
value := row at: colIndex ifAbsent: [ nil ].
2525
dataFrame at: rowIndex at: colIndex put: value ] ].
26-
26+
1 to: numberOfColumns do: [ :colIndex |
27+
dataFrame dataTypes
28+
at: colIndex
29+
put: (dataFrame columnAt: colIndex) calculateDataType ].
2730

2831
^ dataFrame
2932
]

0 commit comments

Comments
 (0)