Powered By GitBook
Series.str.substr
Obtain the substring from a String element in a Series, by specifying the number of string to obtain starting from a specific index.
danfo.Series.str.substr(startIndex, num, options) [source]
Parameters
Type
Description
Default
startIndex
Number
specify the index to start obtaining the substring
0
num
Number
The number of character to obtain starting from the startIndex
1
options
Object
inplace: Whether to perform the operation in-place or not.
{
inplace: false
}
Returns:
return Series
Example
Obtain substring( containing 4 characters) starting from the third character (2nd index).
1
const dfd = require("danfojs-node")
2
3
let data = ['lower part ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe']
4
let sf = new dfd.Series(data)
5
sf.str.substr(2, 4).print()
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0
3
╟───┼──────────────────────╢
4
0 │ wer ║
5
╟───┼──────────────────────╢
6
1APIT
7
╟───┼──────────────────────╢
8
2 │ his ║
9
╟───┼──────────────────────╢
10
3 │ SwAp ║
11
╚═══╧══════════════════════╝
12
Copied!
Last modified 24d ago
Copy link