Skip to content

Commit 91a9bee

Browse files
committed
Added comments for methods in the accessing category of classes DataFrame and DataSeries.
1 parent edd24b8 commit 91a9bee

2 files changed

Lines changed: 63 additions & 18 deletions

File tree

src/DataFrame/DataFrame.class.st

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -485,19 +485,22 @@ DataFrame >> asArrayOfRowsWithName [
485485

486486
{ #category : #accessing }
487487
DataFrame >> at: aNumber [
488-
488+
"Returns the row of a DataFrame at row index aNumber"
489+
489490
^ self rowAt: aNumber
490491
]
491492

492493
{ #category : #accessing }
493494
DataFrame >> at: rowNumber at: columnNumber [
494-
495+
"Returns the value whose row index is rowNumber and column index is columnNumber"
496+
495497
^ contents at: rowNumber at: columnNumber
496498
]
497499

498500
{ #category : #accessing }
499501
DataFrame >> at: rowNumber at: columnNumber put: value [
500-
502+
"Replaces the original value of a DataFrame at row index rowNumber and column index columnNumber with a given value"
503+
501504
contents at: rowNumber at: columnNumber put: value
502505
]
503506

@@ -637,15 +640,17 @@ DataFrame >> column: columnName transform: aBlock ifAbsent: exceptionBlock [
637640

638641
{ #category : #accessing }
639642
DataFrame >> columnAt: aNumber [
640-
643+
"Returns the column of a DataFrame at column index aNumber"
644+
641645
^ (DataSeries withKeys: self rowNames values: (contents columnAt: aNumber))
642646
name: (self columnNames at: aNumber);
643647
yourself
644648
]
645649

646650
{ #category : #accessing }
647651
DataFrame >> columnAt: aNumber put: anArray [
648-
652+
"Replaces the column at column index aNumber with contents of the array anArray"
653+
649654
anArray size = self numberOfRows
650655
ifFalse: [ SizeMismatch signal ].
651656

@@ -662,13 +667,15 @@ DataFrame >> columnAt: aNumber transform: aBlock [
662667

663668
{ #category : #accessing }
664669
DataFrame >> columnNames [
665-
670+
"Returns the column names of a DataFrame"
671+
666672
^ columnNames
667673
]
668674

669675
{ #category : #accessing }
670676
DataFrame >> columnNames: aCollection [
671-
677+
"Sets the column names of a DataFrame with contents of the collection aCollection"
678+
672679
| type |
673680
aCollection size = self numberOfColumns
674681
ifFalse: [ SizeMismatch signal: 'Wrong number of column names' ].
@@ -695,7 +702,8 @@ DataFrame >> columns [
695702

696703
{ #category : #accessing }
697704
DataFrame >> columns: anArrayOfNames [
698-
705+
"Returns a collection of columns whose column names are present in the array anArrayOfNames"
706+
699707
| anArrayOfNumbers |
700708

701709
anArrayOfNumbers := anArrayOfNames
@@ -707,6 +715,7 @@ DataFrame >> columns: anArrayOfNames [
707715

708716
{ #category : #accessing }
709717
DataFrame >> columns: anArrayOfColumnNames put: anArrayOfArrays [
718+
"Replaces the columns whose column names are present in the array anArrayOfColumnNames with the contents of the array of arrays anArrayOfArrays"
710719

711720
anArrayOfArrays size = anArrayOfColumnNames size
712721
ifFalse: [ SizeMismatch signal ].
@@ -717,6 +726,7 @@ DataFrame >> columns: anArrayOfColumnNames put: anArrayOfArrays [
717726

718727
{ #category : #accessing }
719728
DataFrame >> columnsAt: anArrayOfNumbers [
729+
"Returns a collection of columns whose column indices are present in the array anArrayOfNumbers"
720730

721731
| newColumnNames |
722732

@@ -731,6 +741,7 @@ DataFrame >> columnsAt: anArrayOfNumbers [
731741

732742
{ #category : #accessing }
733743
DataFrame >> columnsAt: anArrayOfNumbers put: anArrayOfArrays [
744+
"Replaces the columns whose column indices are present in the array anArrayOfNumbers with the contents of the array of arrays anArrayOfArrays"
734745

735746
anArrayOfArrays size = anArrayOfNumbers size
736747
ifFalse: [ SizeMismatch signal ].
@@ -741,6 +752,7 @@ DataFrame >> columnsAt: anArrayOfNumbers put: anArrayOfArrays [
741752

742753
{ #category : #accessing }
743754
DataFrame >> columnsFrom: begin to: end [
755+
"Returns a collection of columns whose column indices are present between begin and end"
744756

745757
| array |
746758

@@ -753,6 +765,7 @@ DataFrame >> columnsFrom: begin to: end [
753765

754766
{ #category : #accessing }
755767
DataFrame >> columnsFrom: firstNumber to: secondNumber put: anArrayOfArrays [
768+
"Replaces the columns whose column indices are present between firstNumber and secondNumber with the contents of the array of arrays anArrayOfArrays"
756769

757770
| interval |
758771

@@ -827,6 +840,7 @@ DataFrame >> correlationMatrixUsing: aCorrelationCoefficient [
827840

828841
{ #category : #accessing }
829842
DataFrame >> crossTabulate: colName1 with: colName2 [
843+
"Returns the cross tabulation of a column named colName1 with the column named colName2 of the DataFrame"
830844

831845
| col1 col2 |
832846

@@ -866,7 +880,8 @@ DataFrame >> dataTypeOfColumnAt: aNumber put: aDataType [
866880

867881
{ #category : #accessing }
868882
DataFrame >> dataTypes [
869-
883+
"Returns the data types of each column"
884+
870885
^ dataTypes
871886
]
872887

@@ -884,7 +899,8 @@ DataFrame >> defaultHeadTailSize [
884899

885900
{ #category : #accessing }
886901
DataFrame >> dimensions [
887-
902+
"Returns the number of rows and number of columns in a DataFrame"
903+
888904
^ (self numberOfRows) @ (self numberOfColumns)
889905
]
890906

@@ -918,7 +934,8 @@ DataFrame >> findAllIndicesOf: anObject atColumn: columnName [
918934

919935
{ #category : #accessing }
920936
DataFrame >> first [
921-
937+
"Returns the first row of the DataFrame"
938+
922939
^ self at: 1
923940
]
924941

@@ -1005,13 +1022,15 @@ DataFrame >> hasNilsByColumn [
10051022

10061023
{ #category : #accessing }
10071024
DataFrame >> head [
1008-
1025+
"Returns the first 5 rows of the DataFrame"
1026+
10091027
^ self head: self defaultHeadTailSize
10101028
]
10111029

10121030
{ #category : #accessing }
10131031
DataFrame >> head: aNumber [
1014-
1032+
"Returns the first aNumber rows of a DataFrame"
1033+
10151034
^ self rowsAt: (1 to: (self numberOfRows min: aNumber))
10161035
]
10171036

@@ -1330,7 +1349,8 @@ DataFrame >> normalized [
13301349

13311350
{ #category : #accessing }
13321351
DataFrame >> numberOfColumns [
1333-
1352+
"Returns the number of columns of a DataFrame"
1353+
13341354
^ contents numberOfColumns
13351355
]
13361356

@@ -1347,6 +1367,7 @@ DataFrame >> numberOfNils [
13471367

13481368
{ #category : #accessing }
13491369
DataFrame >> numberOfRows [
1370+
"Returns the number of rows of a DataFrame"
13501371

13511372
^ contents numberOfRows
13521373
]
@@ -1831,6 +1852,7 @@ DataFrame >> row: rowName transform: aBlock ifAbsent: exceptionBlock [
18311852

18321853
{ #category : #accessing }
18331854
DataFrame >> rowAt: aNumber [
1855+
"Returns the row of a DataFrame at row index aNumber"
18341856

18351857
| series |
18361858
series := (contents rowAt: aNumber) asDataSeries.
@@ -1841,6 +1863,7 @@ DataFrame >> rowAt: aNumber [
18411863

18421864
{ #category : #accessing }
18431865
DataFrame >> rowAt: aNumber put: anArray [
1866+
"Replaces the row at row index aNumber with contents of the array anArray"
18441867

18451868
anArray size = self numberOfColumns
18461869
ifFalse: [ SizeMismatch signal ].
@@ -1858,12 +1881,14 @@ DataFrame >> rowAt: aNumber transform: aBlock [
18581881

18591882
{ #category : #accessing }
18601883
DataFrame >> rowNames [
1861-
1884+
"Returns the row names of a DataFrame"
1885+
18621886
^ rowNames
18631887
]
18641888

18651889
{ #category : #accessing }
18661890
DataFrame >> rowNames: anArray [
1891+
"Sets the row names of a DataFrame with contents of the collection aCollection"
18671892

18681893
anArray size = self numberOfRows ifFalse: [ SizeMismatch signal: 'Wrong number of row names' ].
18691894

@@ -1874,6 +1899,7 @@ DataFrame >> rowNames: anArray [
18741899

18751900
{ #category : #accessing }
18761901
DataFrame >> rows: anArrayOfNames [
1902+
"Returns a collection of rows whose row names are present in the array anArrayOfNames"
18771903

18781904
| anArrayOfNumbers |
18791905

@@ -1886,6 +1912,7 @@ DataFrame >> rows: anArrayOfNames [
18861912

18871913
{ #category : #accessing }
18881914
DataFrame >> rows: anArrayOfRowNames put: anArrayOfArrays [
1915+
"Replaces the rows whose row names are present in the array anArrayOfRowNames with the contents of the array of arrays anArrayOfArrays"
18891916

18901917
anArrayOfArrays size = anArrayOfRowNames size
18911918
ifFalse: [ SizeMismatch signal ].
@@ -1896,6 +1923,7 @@ DataFrame >> rows: anArrayOfRowNames put: anArrayOfArrays [
18961923

18971924
{ #category : #accessing }
18981925
DataFrame >> rowsAt: anArrayOfNumbers [
1926+
"Returns a collection of rows whose row indices are present in the array anArrayOfNumbers"
18991927

19001928
| newRowNames |
19011929

@@ -1910,6 +1938,7 @@ DataFrame >> rowsAt: anArrayOfNumbers [
19101938

19111939
{ #category : #accessing }
19121940
DataFrame >> rowsAt: anArrayOfNumbers put: anArrayOfArrays [
1941+
"Replaces the rows whose row indices are present in the array anArrayOfNumbers with the contents of the array of arrays anArrayOfArrays"
19131942

19141943
anArrayOfArrays size = anArrayOfNumbers size
19151944
ifFalse: [ SizeMismatch signal ].
@@ -1920,12 +1949,14 @@ DataFrame >> rowsAt: anArrayOfNumbers put: anArrayOfArrays [
19201949

19211950
{ #category : #accessing }
19221951
DataFrame >> rowsFrom: begin to: end [
1952+
"Returns a collection of rows whose row indices are present between begin and end"
19231953

19241954
^ self rowsAt: (begin to: end)
19251955
]
19261956

19271957
{ #category : #accessing }
19281958
DataFrame >> rowsFrom: firstNumber to: secondNumber put: anArrayOfArrays [
1959+
"Replaces the rows whose row indices are present between firstNumber and secondNumber with the contents of the array of arrays anArrayOfArrays"
19291960

19301961
| interval |
19311962

@@ -1963,6 +1994,8 @@ DataFrame >> setDefaultRowColumnNames [
19631994

19641995
{ #category : #accessing }
19651996
DataFrame >> size [
1997+
"Returns the number of rows of a DataFrame"
1998+
19661999
^ self numberOfRows
19672000
]
19682001

@@ -2003,13 +2036,14 @@ DataFrame >> stdev [
20032036

20042037
{ #category : #accessing }
20052038
DataFrame >> tail [
2006-
2039+
"Returns the last 5 rows of a DataFrame"
2040+
20072041
^ self tail: self defaultHeadTailSize
20082042
]
20092043

20102044
{ #category : #accessing }
20112045
DataFrame >> tail: aNumber [
2012-
2046+
"Returns the last aNumber rows of aDataFrame"
20132047
| rows |
20142048
rows := self numberOfRows.
20152049

src/DataFrame/DataSeries.class.st

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,22 @@ DataSeries >> at: aKey transform: aBlock ifAbsent: exceptionBlock [
138138

139139
{ #category : #accessing }
140140
DataSeries >> atAll: aCollectionOfIndexes [
141-
141+
"Returns a data series of only those elements of the receiver whose indices are present in the collection aCollectionOfIndexes"
142+
142143
^ self withIndexSelect: [ :each :index | aCollectionOfIndexes includes: index ]
143144
]
144145

145146
{ #category : #accessing }
146147
DataSeries >> atIndex: aNumber [
148+
"Answer the element of the receiver at index aNumber"
149+
147150
^ self at: (self keys at: aNumber)
148151
]
149152

150153
{ #category : #accessing }
151154
DataSeries >> atIndex: aNumber put: aValue [
155+
"Replace the element of the receiver at index aNumber with the value aValue"
156+
152157
^ self at: (self keys at: aNumber) put: aValue
153158
]
154159

@@ -486,11 +491,15 @@ DataSeries >> mode [
486491

487492
{ #category : #accessing }
488493
DataSeries >> name [
494+
"Answer the name of the receiver"
495+
489496
^ name
490497
]
491498

492499
{ #category : #accessing }
493500
DataSeries >> name: anObject [
501+
"Set the name of the receiver to anObject"
502+
494503
name := anObject
495504
]
496505

@@ -741,6 +750,8 @@ DataSeries >> thirdQuartile [
741750

742751
{ #category : #accessing }
743752
DataSeries >> uniqueValues [
753+
"Answer the unique values of the receiver"
754+
744755
^ self asSet asArray
745756
]
746757

0 commit comments

Comments
 (0)