Skip to content

Commit 4be99a0

Browse files
committed
Raise error if value to transform does not exists
1 parent 03de960 commit 4be99a0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/DataFrame/DataFrame.class.st

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,10 +856,14 @@ DataFrame >> crossTabulate: colName1 with: colName2 [
856856
DataFrame >> dataPreProcessingEncodeWith: anEncoder [
857857
"This method is here to speed up pharo-ai/data-preprocessing algos without coupling both projects."
858858

859-
| copy |
859+
| copy cache |
860860
copy := self copy.
861+
cache := IdentityDictionary new.
861862
self columns doWithIndex: [ :dataSerie :columnIndex |
862-
dataSerie doWithIndex: [ :element :rowIndex | copy at: rowIndex at: columnIndex put: ((anEncoder categories at: columnIndex) indexOf: element) ] ].
863+
| category |
864+
category := cache at: columnIndex ifAbsentPut: [ ((anEncoder categories at: columnIndex) collectWithIndex: [ :elem :index | elem -> index ]) asDictionary ].
865+
dataSerie doWithIndex: [ :element :rowIndex |
866+
copy at: rowIndex at: columnIndex put: (category at: element ifAbsent: [ AIMissingCategory signalFor: element ]) ] ].
863867

864868
^ copy
865869
]

0 commit comments

Comments
 (0)