Series.str.search

Obtain the index position of a searched character in a String

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

Parameters

Type

Description

Default

str

String

the string to search for

""

Returns:

return Series: Series of index position

Example

obtain the index position for a character

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

Obtain the index position for a searched word

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