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
const dfd = require("danfojs-node")
let data = ['lower part ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe']
let sf = new dfd.Series(data)
sf.str.search("S").print()
Output
╔═══╤══════════════════════╗
║ │ 0 ║
╟───┼──────────────────────╢
║ 0 │ -1 ║
╟───┼──────────────────────╢
║ 1 │ 8 ║
╟───┼──────────────────────╢
║ 2 │ -1 ║
╟───┼──────────────────────╢
║ 3 │ 2 ║
╚═══╧══════════════════════╝
Obtain the index position for a searched word
Node
Browser
const dfd = require("danfojs-node")
let data = ['lower city ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe']
let sf = new dfd.Series(data)
sf.str.search("city").print()
Output
╔═══╤══════════════════════╗
║ │ 0 ║
╟───┼──────────────────────╢
║ 0 │ 6 ║
╟───┼──────────────────────╢
║ 1 │ 10 ║
╟───┼──────────────────────╢
║ 2 │ -1 ║
╟───┼──────────────────────╢
║ 3 │ -1 ║
╚═══╧══════════════════════╝
Copy link