diff --git a/src/DataFrame-Tests/DataFrameTest.class.st b/src/DataFrame-Tests/DataFrameTest.class.st index 921b2002..6a27236e 100644 --- a/src/DataFrame-Tests/DataFrameTest.class.st +++ b/src/DataFrame-Tests/DataFrameTest.class.st @@ -922,6 +922,19 @@ DataFrameTest >> testColumns [ self assert: df columns equals: expectedCollection ] +{ #category : 'tests' } +DataFrameTest >> testColumnsAllBut [ + + | expectedDataFrame | + expectedDataFrame := DataFrame withRows: #( #( 'Barcelona' 1.609 ) #( 'Dubai' 2.789 ) #( 'London' 8.788 ) ). + expectedDataFrame rowNames: #( 'A' 'B' 'C' ). + expectedDataFrame columnNames: #( 'City' 'Population'). + + self + assert: (df columnsAllBut: #(BeenThere)) + equals: expectedDataFrame +] + { #category : 'tests' } DataFrameTest >> testColumnsAt [ @@ -5171,22 +5184,24 @@ DataFrameTest >> testShuffledWithSeed [ | expected | - "df = A Barcelona B Dubai C London" expected := DataFrame withRows: #( ('Barcelona' 1.609 true) ('London' 8.788 false) ('Dubai' 2.789 true)). + expected rowNames: #( 'A' 'C' 'B'). + expected columnNames: #( 'City' 'Population' 'BeenThere' ). self assert: (df shuffleWithSeed: 1) equals: expected. - - self assert: (df shuffleWithSeed: 2) equals: expected. expected := DataFrame withRows: #( - ('London' 8.788 false) - ('Barcelona' 1.609 true) - ('Dubai' 2.789 true)). + ('Dubai' 2.789 true) + ('Barcelona' 1.609 true) + ('London' 8.788 false) ). + expected rowNames: #('B' 'A' 'C'). + expected columnNames: #( 'City' 'Population' 'BeenThere' ). + self assert: (df shuffleWithSeed: 2) equals: expected. - self assert: (df shuffleWithSeed: 3) equals: expected. + ] { #category : 'tests' } diff --git a/src/DataFrame/DataFrame.class.st b/src/DataFrame/DataFrame.class.st index cde82174..1f42e47b 100644 --- a/src/DataFrame/DataFrame.class.st +++ b/src/DataFrame/DataFrame.class.st @@ -851,6 +851,13 @@ DataFrame >> columns: anArrayOfColumnNames put: anArrayOfArrays [ self column: name put: array ] ] +{ #category : 'accessing' } +DataFrame >> columnsAllBut: aCollectionOfColumnNames [ + "Returns a of except those present in aCollectionOfColumnNames" + + ^ self columns: (self columnNames copyWithoutAll: aCollectionOfColumnNames) +] + { #category : 'accessing' } DataFrame >> columnsAt: anArrayOfNumbers [ "Returns a collection of columns whose column indices are present in the array anArrayOfNumbers" @@ -2441,6 +2448,12 @@ DataFrame >> shuffleWithSeed: aNumber [ ^ self shuffleBy: (Random new seed: aNumber) ] +{ #category : 'accessing' } +DataFrame >> shuffled [ + + self shuffleBy: Random new +] + { #category : 'accessing' } DataFrame >> size [ "Returns the number of rows of a DataFrame"