Powered By GitBook
Series.str.concat
Joins two or more strings/arrays
danfo.Series.str.concat(other, position, options) [source]
Parameters
Type
Description
Default
other
string or Array
string or list of strings to add to each string element of the series
""
position
Int
The position to add the other (string or array) is either 0 or 1. 0 is to add the other at the beginning of each of the string element, and 1 is to add to the end of the string element
1
options
Object
inplace: Whether to perform the operation in-place or not.
{
inplace: false
}
Returns: Series (String element)
Examples
Add the strings from an Array to the start of each of the String element in Series
Node
Browser
1
const dfd = require("danfojs-node")
2
3
let data = ['lower boy', 'CAPITALS', 'sentence', 'SwApCaSe']
4
let data2 = ['XX', 'YY', 'BB', '01']
5
let sf = new dfd.Series(data)
6
sf.str.concat(data2,0).print()
Copied!
1
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ XXlower boy ║
5
╟───┼──────────────────────╢
6
║ 1 │ YYCAPITALS ║
7
╟───┼──────────────────────╢
8
║ 2 │ BBsentence ║
9
╟───┼──────────────────────╢
10
║ 3 │ 01SwApCaSe ║
11
╚═══╧══════════════════════╝
Copied!
Add the strings from an Array to the end of each of the String element in Series
Node
Browser
1
const dfd = require("danfojs-node")
2
3
let data = ['lower boy', 'CAPITALS', 'sentence', 'SwApCaSe']
4
let data2 = ['XX', 'YY', 'BB', '01']
5
let sf = new dfd.Series(data)
6
sf.str.concat(data2,1).print()
Copied!
1
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ lower boyXX ║
5
╟───┼──────────────────────╢
6
║ 1 │ CAPITALSYY ║
7
╟───┼──────────────────────╢
8
║ 2 │ sentenceBB ║
9
╟───┼──────────────────────╢
10
║ 3 │ SwApCaSe01 ║
11
╚═══╧══════════════════════╝
Copied!
Add a string to the start of each string element in a Series
Output
Browser
1
const dfd = require("danfojs-node")
2
3
let data = ['lower boy', 'CAPITALS', 'sentence', 'SwApCaSe']
4
let data2 = ['XX', 'YY', 'BB', '01']
5
let sf = new dfd.Series(data)
6
sf.str.concat("pre",0).print()
Copied!
1
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ prelower boy ║
5
╟───┼──────────────────────╢
6
║ 1 │ preCAPITALS ║
7
╟───┼──────────────────────╢
8
║ 2 │ presentence ║
9
╟───┼──────────────────────╢
10
║ 3 │ preSwApCaSe ║
11
╚═══╧══════════════════════╝
Copied!
Add a string to the end of each string element in a series
Node
Browser
1
const dfd = require("danfojs-node")
2
3
let data = ['lower boy', 'CAPITALS', 'sentence', 'SwApCaSe']
4
let data2 = ['XX', 'YY', 'BB', '01']
5
let sf = new dfd.Series(data)
6
sf.str.concat("post",1).print()
Copied!
1
Copied!
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ lower boypost ║
5
╟───┼──────────────────────╢
6
║ 1 │ CAPITALSpost ║
7
╟───┼──────────────────────╢
8
║ 2 │ sentencepost ║
9
╟───┼──────────────────────╢
10
║ 3 │ SwApCaSepost ║
11
╚═══╧══════════════════════╝
Copied!
Last modified 24d ago
Copy link