Series.str.search

Obtain the index position of a searched character in a String

danfo.Series.str.search(str, options) [source]

ParametersTypeDescriptionDefault

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

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()
╔═══╤══════════════════════╗
║   │ 0                    ║
╟───┼──────────────────────╢
║ 0 │ -1                   ║
╟───┼──────────────────────╢
║ 1 │ 8                    ║
╟───┼──────────────────────╢
║ 2 │ -1                   ║
╟───┼──────────────────────╢
║ 3 │ 2                    ║
╚═══╧══════════════════════╝

Obtain the index position for a searched word

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()
╔═══╤══════════════════════╗
║   │ 0                    ║
╟───┼──────────────────────╢
║ 0 │ 6                    ║
╟───┼──────────────────────╢
║ 1 │ 10                   ║
╟───┼──────────────────────╢
║ 2 │ -1                   ║
╟───┼──────────────────────╢
║ 3 │ -1                   ║
╚═══╧══════════════════════╝

Last updated