From 7bf6399d8aa92bed75dfd9a365e1330893897cd4 Mon Sep 17 00:00:00 2001 From: Joshua-Dias-Barreto Date: Wed, 31 May 2023 16:45:45 +0530 Subject: [PATCH] Added a #rows and tests. Fixes #244 --- src/DataFrame-Tests/DataFrameTest.class.st | 12 ++++++++++++ src/DataFrame/DataFrame.class.st | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/src/DataFrame-Tests/DataFrameTest.class.st b/src/DataFrame-Tests/DataFrameTest.class.st index 05db7e61..8e6a58c2 100644 --- a/src/DataFrame-Tests/DataFrameTest.class.st +++ b/src/DataFrame-Tests/DataFrameTest.class.st @@ -4927,6 +4927,18 @@ DataFrameTest >> testRowsFromToPut [ self assert: dataFrame equals: expected ] +{ #category : #tests } +DataFrameTest >> testRowsMethod [ + + | expectedCollection | + expectedCollection := { + (df rowAt: 1). + (df rowAt: 2). + (df rowAt: 3) } asArray. + + self assert: df rows equals: expectedCollection +] + { #category : #tests } DataFrameTest >> testRowsPut [ | rowNames columnNames dataFrame newRows expected | diff --git a/src/DataFrame/DataFrame.class.st b/src/DataFrame/DataFrame.class.st index a3485dfd..5ac0c83e 100644 --- a/src/DataFrame/DataFrame.class.st +++ b/src/DataFrame/DataFrame.class.st @@ -2052,6 +2052,13 @@ DataFrame >> rowNames: anArray [ self privateRowNames: anArray ] +{ #category : #accessing } +DataFrame >> rows [ + "Returns a collection of all rows" + + ^ (1 to: self numberOfRows) collect: [ :j | self rowAt: j ] +] + { #category : #accessing } DataFrame >> rows: anArrayOfNames [ "Returns a collection of rows whose row names are present in the array anArrayOfNames"