# otp.Operation.str.token

#### \_StrAccessor.token(sep=' ', n=0)

Breaks the value into tokens based on the delimiter `sep`
and returns token at position `n` (zero-based).

If there are not enough tokens to get the one at position `n`, then empty string is returned.

* **Parameters:**
  * **sep** ([*str*](https://docs.pip.distribution.sol.onetick.com/api/operation/str/root.html.md#onetick.py.Operation.str) *or* [*Column*](https://docs.pip.distribution.sol.onetick.com/api/operation/root.html.md#onetick.py.Column) *or* [*Operation*](https://docs.pip.distribution.sol.onetick.com/api/operation/root.html.md#onetick.py.Operation)) -- The delimiter, which must be a single character used to split the string into tokens.
  * **n** ([*int*](https://docs.pip.distribution.sol.onetick.com/api/types/int.html.md#onetick.py.int) *,* [*Operation*](https://docs.pip.distribution.sol.onetick.com/api/operation/root.html.md#onetick.py.Operation)) -- Token index to return. For a negative `n`, count from the end instead of the beginning.
    If index is out of range, then empty string is returned.
* **Returns:**
  token at position `n` or empty string.
* **Return type:**
  [Operation](https://docs.pip.distribution.sol.onetick.com/api/operation/root.html.md#onetick.py.Operation)

### Examples

```pycon
>>> data = otp.Tick(X='US_COMP::TRD')
>>> data['Y'] = data['X'].str.token(':', -1)
>>> otp.run(data)
        Time              X    Y
0 2003-12-01  US_COMP::TRD  TRD
```

Other columns can be used as parameters too:

```pycon
>>> data = otp.Tick(X='US_COMP::TRD', SEP=':', N=-1)
>>> data['Y'] = data['X'].str.token(data['SEP'], data['N'])
>>> otp.run(data)
        Time              X SEP  N    Y
0 2003-12-01  US_COMP::TRD   : -1  TRD
```

If index is out of range, then empty string is returned:

```pycon
>>> data = otp.Tick(X='US_COMP::TRD')
>>> data['Y'] = data['X'].str.token(':', 999)
>>> otp.run(data)
        Time              X  Y
0 2003-12-01  US_COMP::TRD
```
