Skip to content

Commit 5e25cd2

Browse files
authored
Update README.md
1 parent e2a6822 commit 5e25cd2

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,32 @@ rows := methods collect: [ :method |
4545
### Creating a DataFrame
4646
We create a DataFrame and specify the names of its columns:
4747
```Smalltalk
48-
methodsData := (DataFrame fromRows: rows)
49-
columnNames: #(packageName className methodName sourceCode);
50-
yourself.
48+
methodsData := DataFrame
49+
withRows: rows
50+
columnNames: #(packageName className methodName sourceCode).
5151
```
5252
### Adding a column
5353
We add a new column with number of arguments for each method. To do that we count the number of occurences of `:` symbol in method's name:
5454
```Smalltalk
55-
methodsData atColumn: #numberOfArgs put:
56-
((methodsData column: #methodName) collect: [ :name |
57-
name occurrencesOf: $: ]).
55+
methodsData
56+
addColumn: ((methodsData column: #methodName)
57+
collect: [ :name | name occurrencesOf: $: ])
58+
named: #numberOfArgs.
5859
```
5960
### Filtering data
6061
Now we select only those methods that belong to package [Renraku](https://github.com/Uko/Renraku), have at least one argument, and source code with less than 5 tokens:
6162
```Smalltalk
6263
renrakuMethods := methodsData select: [ :row |
63-
((row atKey: #packageName) = 'Renraku' and:
64-
(row atKey: #numberOfArgs) > 0) and:
65-
((row atKey: #sourceCode) findTokens: ' ') size < 5 ].
64+
((row at: #packageName) = 'Renraku' and:
65+
(row at: #numberOfArgs) > 0) and:
66+
((row at: #sourceCode) findTokens: ' ') size < 5 ].
6667
```
6768
### Sorting rows by values of a column
6869
First we sort methods by their names and then we sort the result by number of arguments in descending order:
6970
```Smalltalk
7071
renrakuMethods
71-
orderBy: #methodName;
72-
orderDescendingBy: #numberOfArgs.
72+
sortBy: #methodName;
73+
sortDescendingBy: #numberOfArgs.
7374
```
7475
### Selecting specific columns
7576
We selecting only 4 columns (without className) and specify their order. If you inspect the result of this query, you will see the table similar to the one in a screenshot above.

0 commit comments

Comments
 (0)