Series.str.len

Obtain the length of each string element in a Series

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

Parameters: None

Returns:

return Series

Examples

Returns the length (number of character) of a string, and also return the length (number of elements) of Array

JavaScript
Browser
JavaScript
const dfd = require("danfojs-node")
let data = ["dog", 5,"cat",["fog","mug"],"animals"]
let sf = new dfd.Series(data)
sf.str.len().print()
Browser
Output
Output
╔═══╤══════════════════════╗
║ │ 0 ║
╟───┼──────────────────────╢
║ 0 │ 3 ║
╟───┼──────────────────────╢
║ 1 │ NaN ║
╟───┼──────────────────────╢
║ 2 │ 3 ║
╟───┼──────────────────────╢
║ 3 │ 2 ║
╟───┼──────────────────────╢
║ 4 │ 7 ║
╚═══╧══════════════════════╝