From 43f1f9b4c6adf68bbfeac7e8b25771d60e52afb3 Mon Sep 17 00:00:00 2001 From: Joshua-Dias-Barreto Date: Fri, 23 Jun 2023 22:52:35 +0530 Subject: [PATCH 1/2] Fixed #267. #asDataFrame now retains original data types. --- src/DataFrame/Collection.extension.st | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 ] From 822ae9d835bc219e5dcb280d3dccb53f0185cccb Mon Sep 17 00:00:00 2001 From: Joshua-Dias-Barreto Date: Fri, 23 Jun 2023 22:53:42 +0530 Subject: [PATCH 2/2] Added a regression test so that #asDataFrame retains original data types. --- src/DataFrame-Tests/DataFrameTest.class.st | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 [