Powered By GitBook
Series.str.search
Obtain the index position of a searched character in a String
danfo.Series.str.search(str, options) [source]
Parameters
Type
Description
Default
str
String
the string to search for
""
options
Object
inplace: Whether to perform the operation in-place or not.
{
inplace: false
}
Returns:
return Series: Series of index position
Example
obtain the index position for a character
Node
Browser
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.search("S").print()
Copied!
1
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ -1 ║
5
╟───┼──────────────────────╢
6
║ 1 │ 8 ║
7
╟───┼──────────────────────╢
8
║ 2 │ -1 ║
9
╟───┼──────────────────────╢
10
║ 3 │ 2 ║
11
╚═══╧══════════════════════╝
Copied!
Obtain the index position for a searched word
Node
Browser
1
const dfd = require("danfojs-node")
2
3
let data = ['lower city ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe']
4
let sf = new dfd.Series(data)
5
sf.str.search("city").print()
Copied!
1
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ 6 ║
5
╟───┼──────────────────────╢
6
║ 1 │ 10 ║
7
╟───┼──────────────────────╢
8
║ 2 │ -1 ║
9
╟───┼──────────────────────╢
10
║ 3 │ -1 ║
11
╚═══╧══════════════════════╝
Copied!
Last modified 24d ago
Copy link