Skip to content

Commit da44852

Browse files
committed
Update README.md [ci skip]
1 parent 5ca106a commit da44852

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ Keep in mind that both `add:atKey:` and `atKey:put:` messages don't create a new
8282

8383
### Creating DataFrame
8484
There are four ways of creating a data frame:
85-
1. [from an array of rows or columns](#1-creating-dataframe-from-an-array-of-rows-or-columns)
86-
2. [from matrix](#2-creating-dataframe-from-a-matrix)
87-
3. [from file](#3-reading-data-from-file)
88-
4. [loading a built-in dataset](#4-loading-the-built-in-datasets)
85+
[1. from an array of rows or columns](#1-creating-dataframe-from-an-array-of-rows-or-columns)
86+
[2. from matrix](#2-creating-dataframe-from-a-matrix)
87+
[3. from file](#3-reading-data-from-file)
88+
[4. loading a built-in dataset](#4-loading-the-built-in-datasets)
8989

9090
#### 1. Creating DataFrame from an array of rows or columns
9191
The easiest and most straightforward way of creating a DataFrame is by passing all data in an array of arrays to `fromRows:` or `fromColumns:` message. Here is an example of initializing a DataFrame with rows:
@@ -194,6 +194,34 @@ df rowsFrom: 3 to: 1.
194194

195195
The result will be a data frame with requested rows and columns in a given order. For example, the last line will give you a data frame "flipped upside-down" (with row indexes going in the descending order).
196196

197+
You can change the values of a specific row or column by passing an array or series of the same size to one of the messages: `row:put:`, `column:put:`, `rowAt:put:`, `columnAt:put:`. Be careful though, because these messages modify the data frame and may result in the loss of data.
198+
199+
```smalltalk
200+
df column: #BeenThere put: #(false true false).
201+
```
202+
203+
As it was mentioned above, single cell of a data frame can be accessed with `at:at:` and `at:at:put:` messages
204+
205+
```smalltalk
206+
df at: 3 at: 2.
207+
df at: 3 at: 2 put: true.
208+
```
209+
210+
### Adding new rows and columns to DataFrame
211+
New rows and columns can be appended to the data frame using messages `addRow:named` and `addColumn:named`. Like in the case of DataSeries, you must provide a name for these new elements, since it can not continue the existing sequence of names.
212+
213+
```smalltalk
214+
df addRow: #('Lviv' 0.724 true) named: #D.
215+
df addColumn: #(4 3 4) named: #Rating.
216+
```
217+
218+
The same can be done using messages `row:put:` and `column:put:` with non-existing keys. DataFrame will append the new key and associate it with a given row or column
219+
220+
```smalltalk
221+
df at: #D put: #('Lviv' 0.724 true).
222+
df at: #Rating put: #(4 3 4).
223+
```
224+
197225
#### Head & tail
198226
Now let's take a look at some bigger dataset, for example, Boston Housing Data
199227

0 commit comments

Comments
 (0)