Skip to content

Commit 680d904

Browse files
authored
Merge pull request #235 from Joshua-Dias-Barreto/numericalColumn
#columns now returns an collection of series.
2 parents 8704ad2 + 038e3b5 commit 680d904

4 files changed

Lines changed: 11 additions & 13 deletions

File tree

src/DataFrame-IO-Tests/DataFrameCsvReaderTest.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ DataFrameCsvReaderTest >> testReadFromString [
106106
actualDataFrame := DataFrameCsvReader new readFromString: TestCsvStrings commaCsvString.
107107

108108
self
109-
assertCollection: actualDataFrame columns first
109+
assertCollection: actualDataFrame asArrayOfColumns first
110110
hasSameElements: #('1:10 am' '1:30 am' '1:50 am' '2:10 am' '2:30 am').
111111
self
112-
assertCollection: actualDataFrame columns last
112+
assertCollection: actualDataFrame asArrayOfColumns last
113113
hasSameElements: #('rain' 'rain' 'snow' '-' 'rain')
114114
]
115115

src/DataFrame-IO/DataFrameTypeDetector.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ DataFrameTypeDetector >> detectColumnTypeAndConvert: anArray [
146146
{ #category : #'public API' }
147147
DataFrameTypeDetector >> detectTypesAndConvert: aDataFrame [
148148

149-
aDataFrame columns with: aDataFrame columnNames do: [ :column :columnName |
149+
aDataFrame asArrayOfColumns with: aDataFrame columnNames do: [ :column :columnName |
150150
| thisColumnType |
151151
"Get the user given column type for this column name and if it wasn't
152152
given then use the default type detection"

src/DataFrame-Tests/DataFrameTest.class.st

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -758,11 +758,10 @@ DataFrameTest >> testColumnTransformNotFound [
758758
DataFrameTest >> testColumns [
759759

760760
| expectedCollection |
761-
762-
expectedCollection := #(
763-
(Barcelona Dubai London)
764-
(1.609 2.789 8.788)
765-
(true true false)).
761+
expectedCollection := {
762+
(df columnAt: 1).
763+
(df columnAt: 2).
764+
(df columnAt: 3) } asArray.
766765

767766
self assert: df columns equals: expectedCollection
768767
]

src/DataFrame/DataFrame.class.st

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ DataFrame >> average [
543543
{ #category : #'data-types' }
544544
DataFrame >> calculateDataTypes [
545545

546-
self columns doWithIndex: [ :column :i | self dataTypes at: (self columnNames at: i) put: column calculateDataType ]
546+
self asArrayOfColumns doWithIndex: [ :column :i | self dataTypes at: (self columnNames at: i) put: column calculateDataType ]
547547
]
548548

549549
{ #category : #comparing }
@@ -722,10 +722,9 @@ DataFrame >> columnNames: aCollection [
722722

723723
{ #category : #accessing }
724724
DataFrame >> columns [
725-
726725
"Returns a collection of all columns"
727726

728-
^ self asArrayOfColumns
727+
^ (1 to: self numberOfColumns) collect: [ :j | self columnAt: j ]
729728
]
730729

731730
{ #category : #accessing }
@@ -1053,7 +1052,7 @@ DataFrame >> hasNils [
10531052
"Returns true if there is atleast one nil value in the data frame. Returns false if there are no nil values in the dataframe"
10541053

10551054
| arrayOfColumns |
1056-
arrayOfColumns := self columns.
1055+
arrayOfColumns := self asArrayOfColumns.
10571056
1 to: self numberOfColumns do: [ :column |
10581057
1 to: self numberOfRows do: [ :row |
10591058
((arrayOfColumns at: column) at: row) ifNil: [ ^ true ] ] ].
@@ -1397,7 +1396,7 @@ DataFrame >> normalized [
13971396
'DataFrame will remove the dependency over normalization in the next version. You can use pharo-ai/data-preprocessing project to normalize your DataFrame and even more!'.
13981397
normalizers := (1 to: self anyOne size) collect: [ :e | self class defaultNormalizerClass new ].
13991398

1400-
normalizedColumns := self columns with: normalizers collect: [ :col :normalizer | col normalizedUsing: normalizer ].
1399+
normalizedColumns := self asArrayOfColumns with: normalizers collect: [ :col :normalizer | col normalizedUsing: normalizer ].
14011400

14021401
^ self class withColumns: normalizedColumns columnNames: self columnNames
14031402
]

0 commit comments

Comments
 (0)