Skip to content

Commit 8f5acbb

Browse files
committed
Implemented some API queries
1 parent 6e83bdc commit 8f5acbb

File tree

6 files changed

+35
-18
lines changed

6 files changed

+35
-18
lines changed

DataFrame-Core.package/DataFrame.class/class/fromXLSX..st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fromXLSX: pathToFile
44
| file workbook sheet |
55

66
file := FileStream readOnlyFileNamed: pathToFile.
7-
workbook := XLSXImporter import file.
7+
workbook := XLSXImporter import: file.
88
sheet := workbook worksheets first.
99

1010
^ self fromXLSXworksheet: sheet.

DataFrame-Core.package/DataFrame.class/class/fromXLSXworksheet..st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ fromXLSXworksheet: sheet
44
| matrix df |
55

66
matrix := sheet cellValuesAsMatrix.
7-
df := self new initializeMatrix: matrix.
7+
df := self new initializeMatrix: matrix.
8+
^ df
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
as yet unclassified
2+
select: colNames where: aBlock
3+
4+
^ (self selectAllWhere: aBlock) columns: colNames
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
as yet unclassified
2+
select: colNames where: aBlock groupBy: aColName aggregate: selector
3+
4+
^ ((self select: colNames where: aBlock)
5+
groupBy: aColName) perform: selector.
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
enumerating
2-
select: aBlock with: anArray
2+
select: aBlock with: testedColumnNames
33

4-
( anArray size = 1 ) ifTrue: [
5-
^ self select: [ :row |
6-
aBlock value: (row atKey: (anArray at: 1)) ] ].
4+
| blockStr |
5+
blockStr := aBlock asString.
76

8-
( anArray size = 2 ) ifTrue: [
9-
^ self select: [ :row |
10-
aBlock
11-
value: (row atKey: (anArray at: 1))
12-
value: (row atKey: (anArray at: 2)) ] ].
7+
"Remove parameters: '[ :x | x > 3 ]' to '[ x > 3 ]'"
8+
blockStr := (blockStr
9+
copyFrom: (blockStr findString: '|')
10+
to: blockStr size).
1311

14-
( anArray size = 3 ) ifTrue: [
15-
^ self select: [ :row |
16-
aBlock
17-
value: (row atKey: (anArray at: 1))
18-
value: (row atKey: (anArray at: 2))
19-
value: (row atKey: (anArray at: 3)) ] ].
12+
testedColumnNames do: [ :eachColName |
13+
blockStr := blockStr
14+
copyReplaceAll: eachColName
15+
with: ('(row atKey: #', eachColName, ')') ].
2016

21-
Error signal: 'Too many arguments'.
17+
blockStr := '[ :row ', blockStr.
18+
^ self select: (Compiler evaluate: blockStr)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
as yet unclassified
2+
selectAllWhere: aBlock
3+
4+
| testedColumnNames |
5+
testedColumnNames := aBlock argumentNames.
6+
7+
(self columnNames includesAll: testedColumnNames)
8+
ifFalse: [ Error signal: 'All arguments of the where block must correspond to the column names of a data frame' ].
9+
10+
^ self select: aBlock with: testedColumnNames

0 commit comments

Comments
 (0)