@@ -113,6 +113,8 @@ DataSeries >> adaptToCollection: rcvr andSend: selector [
113113
114114{ #category : #converting }
115115DataSeries >> asDataFrame [
116+ " Converts a data series to a data frame with 1 column. The values in the column of the data frame are the values of the data series. The row names of this data frame are the keys of the data series. The column name of the data frame is same as the name of the data series"
117+
116118 ^ DataFrame
117119 withColumns: { self values }
118120 rowNames: self keys
@@ -207,6 +209,8 @@ DataSeries >> closeTo: anObject precision: aPrecision [
207209
208210{ #category : #enumerating }
209211DataSeries >> collect: aBlock [
212+ " Applies aBlock to every element"
213+
210214 | result |
211215 result := super collect: aBlock.
212216 result name: self name.
@@ -403,11 +407,15 @@ DataSeries >> hasNil [
403407
404408{ #category : #slicing }
405409DataSeries >> head [
410+ " Returns a data series with first 5 elements of the receiver"
411+
406412 ^ self head: self defaultHeadTailSize
407413]
408414
409415{ #category : #slicing }
410416DataSeries >> head: aNumber [
417+ " Returns a data series with first aNumber elements of the receiver"
418+
411419 ^ self species
412420 withKeys: (self keys copyFrom: 1 to: aNumber)
413421 values: (self values copyFrom: 1 to: aNumber)
@@ -436,12 +444,15 @@ DataSeries >> interquartileRange [
436444
437445{ #category : #' categorical-numerical' }
438446DataSeries >> isCategorical [
447+ " Returns true if atleast one value of the data series is non numerical and returns false otherwise"
448+
439449 ^ self isNumerical not
440450]
441451
442452{ #category : #' categorical-numerical' }
443453DataSeries >> isNumerical [
444-
454+ " Returns true if all values of the data series are numerical values and returns false otherwise"
455+
445456 ^ forcedIsNumerical ifNil: [ (self uniqueValues copyWithout: nil ) allSatisfy: [ :each | each isNumber ] ]
446457]
447458
@@ -472,11 +483,15 @@ DataSeries >> log: base [
472483
473484{ #category : #' categorical-numerical' }
474485DataSeries >> makeCategorical [
486+ " Converts a data series to a categorical data series"
487+
475488 forcedIsNumerical := false
476489]
477490
478491{ #category : #' categorical-numerical' }
479492DataSeries >> makeNumerical [
493+ " Converts a data series to a numerical data series"
494+
480495 forcedIsNumerical := true
481496]
482497
@@ -542,16 +557,22 @@ DataSeries >> reject: aBlock [
542557
543558{ #category : #removing }
544559DataSeries >> removeAt: aKey [
560+ " Removes element from the data series with key aKey"
561+
545562 ^ self removeKey: aKey
546563]
547564
548565{ #category : #removing }
549566DataSeries >> removeAtIndex: aNumber [
567+ " Removes element from the data series with index aNumber"
568+
550569 ^ self removeAt: (self keys at: aNumber)
551570]
552571
553572{ #category : #removing }
554573DataSeries >> removeNils [
574+ " Removes elements with nil values from the data series"
575+
555576 ^ self reject: [ :ele | ele isNil ]
556577]
557578
@@ -645,11 +666,15 @@ DataSeries >> sixth [
645666
646667{ #category : #sorting }
647668DataSeries >> sort [
669+ " Arranges a data series in ascending order of its values"
670+
648671 self sort: [ :a :b | a <= b ]
649672]
650673
651674{ #category : #sorting }
652675DataSeries >> sort: aBlock [
676+ " Arranges a data series by applying aBlock on its values"
677+
653678 | associationBlock |
654679 associationBlock := [ :a :b | aBlock value: a value value: b value ].
655680 self sortAssociations: associationBlock
@@ -665,6 +690,8 @@ DataSeries >> sortAssociations: aBlock [
665690
666691{ #category : #sorting }
667692DataSeries >> sortDescending [
693+ " Arranges a data series in descending order of its values"
694+
668695 self sort: [ :a :b | a > b ]
669696]
670697
@@ -723,11 +750,15 @@ DataSeries >> summary [
723750
724751{ #category : #slicing }
725752DataSeries >> tail [
753+ " Returns a data series with last 5 elements of the receiver"
754+
726755 ^ self tail: self defaultHeadTailSize
727756]
728757
729758{ #category : #slicing }
730759DataSeries >> tail: aNumber [
760+ " Returns a data series with last aNumber elements of the receiver"
761+
731762 ^ self species
732763 withKeys: (self keys copyFrom: self size - aNumber + 1 to: self size)
733764 values: (self values copyFrom: self size - aNumber + 1 to: self size)
0 commit comments