diff --git a/src/DataFrame-Tests/DataFrameTest.class.st b/src/DataFrame-Tests/DataFrameTest.class.st index 40b837a3..f45dc9fb 100644 --- a/src/DataFrame-Tests/DataFrameTest.class.st +++ b/src/DataFrame-Tests/DataFrameTest.class.st @@ -433,6 +433,21 @@ DataFrameTest >> testAsDataFrame [ self assert: actual equals: expected ] +{ #category : #tests } +DataFrameTest >> testAsDataFrameDataTypes [ + + | actual expected | + actual := #( #( a 1 3.1 ) + #( b 2 6.5 ) + #( c 3 9.7 ) ) asDataFrame dataTypes. + expected := Dictionary newFrom: { + (1 -> Object). + (2 -> SmallInteger). + (3 -> SmallFloat64) }. + + self assert: actual equals: expected +] + { #category : #tests } DataFrameTest >> testAsDataFrameEmpty [ diff --git a/src/DataFrame/Collection.extension.st b/src/DataFrame/Collection.extension.st index fbf0b28e..30df4bf0 100644 --- a/src/DataFrame/Collection.extension.st +++ b/src/DataFrame/Collection.extension.st @@ -23,7 +23,10 @@ Collection >> asDataFrame [ | value | value := row at: colIndex ifAbsent: [ nil ]. dataFrame at: rowIndex at: colIndex put: value ] ]. - + 1 to: numberOfColumns do: [ :colIndex | + dataFrame dataTypes + at: colIndex + put: (dataFrame columnAt: colIndex) calculateDataType ]. ^ dataFrame ]