Skip to content

Commit 99872bf

Browse files
Runnable examples for applying methods of DataFrame.
1 parent 8cf1522 commit 99872bf

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/DataFrame/DataFrame.class.st

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ DataFrame >> addRow: anArray named: aString atPosition: aNumber [
459459
DataFrame >> applyElementwise: aBlock [
460460
"Applies a given block to all columns of a data frame"
461461

462+
"(#(#(1 2) #(3 4)) asDataFrame applyElementwise:[ :x | x - 1 ]) >>> (#(#(0 1) #(2 3)) asDataFrame)"
463+
462464
self toColumns: self columnNames applyElementwise: aBlock
463465
]
464466

@@ -2389,6 +2391,8 @@ DataFrame >> toColumn: columnName applyElementwise: aBlock [
23892391
DataFrame >> toColumnAt: columnNumber applyElementwise: aBlock [
23902392
"Applies a given block to a column whose column index is columnNumber of a data frame"
23912393

2394+
"(#(#(1 2) #(3 4)) asDataFrame toColumnAt: 1 applyElementwise:[ :x | x - 1 ]) >>> (#(#(0 2) #(2 4)) asDataFrame)"
2395+
23922396
| columnName |
23932397
columnName := self columnNames at: columnNumber.
23942398
^ self toColumn: columnName applyElementwise: aBlock
@@ -2406,6 +2410,8 @@ DataFrame >> toColumns: arrayOfColumnNames applyElementwise: aBlock [
24062410
DataFrame >> toColumnsAt: arrayOfColumnNumbers applyElementwise: aBlock [
24072411
"Applies a given block to columns whose indices are present in the array arrayOfColumnNumbers of a data frame"
24082412

2413+
"(#(#(1 2) #(3 4)) asDataFrame toColumnsAt: #(1 2) applyElementwise:[ :x | x - 1 ]) >>> (#(#(0 1) #(2 3)) asDataFrame)"
2414+
24092415
arrayOfColumnNumbers do: [ :each |
24102416
self toColumnAt: each applyElementwise: aBlock ]
24112417
]

0 commit comments

Comments
 (0)