Skip to content

Commit 6e83bdc

Browse files
committed
Update README.md [ci skip]
1 parent 2788033 commit 6e83bdc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ newSeries name. "letters"
6363
newSeries atKey: 'k1'. "ax"
6464
```
6565

66+
### Adding new elements to DataSeries
67+
Since all the elements of DataSeries are expected to have keys, in order to add a new element you must specify a key that should be associated with it
68+
69+
```smalltalk
70+
series add: 'x' atKey: #k4.
71+
```
72+
73+
In future there will also be an `add:` message that will choose a default key value or even predict the next element of a sequence of keys. For example, if keys are `#(1 2 3 4 5)`, the new element will be associated with key `6`, if the sequence of keys is `#(2 4 6)`, the next key will be `8`. Perhaps, it will even be possible to predict the next key in symbolic sequences, such as `#(a b c d)` or `#(k1 k2 k3)`. Such functionality is not easy to implement, so we leave it for future releases of DataFrame library.
74+
75+
Another way of adding an element to DataSeries is by using the `atKey:put:` message with a non-existing key. Inspired by Pandas, `atKey:put:` modifies an element at a given key if such key exists in a DataSeries, or adds a new element associeted with that key, if it wasn't found.
76+
77+
```smalltalk
78+
series atKey: #k4 put: 'x'.
79+
```
80+
81+
Keep in mind that both `add:atKey:` and `atKey:put:` messages don't create a new series, but modify the existing one. So use them with caution.
82+
6683
### Creating a DataFrame
6784
There are four ways of creating a data frame:
6885
1. Creating an empty data frame, then filling it with data

0 commit comments

Comments
 (0)