numpy.char.splitlines#

char.splitlines(a, keepends=None)[source]#

For each element in a, return a list of the lines in the element, breaking at line boundaries.

Calls str.splitlines element-wise.

Parameters:
aarray-like, with StringDType, bytes_, or str_ dtype
keependsbool, optional

Line breaks are not included in the resulting list unless keepends is given and true.

Returns:
outndarray

Array of list objects

See also

str.splitlines

Examples

>>> np.char.splitlines("first line\nsecond line")
array(list(['first line', 'second line']), dtype=object)
>>> a = np.array(["first\nsecond", "third\nfourth"])
>>> np.char.splitlines(a)
array([list(['first', 'second']), list(['third', 'fourth'])], dtype=object)