chevron_left
Char
Method addMethod capitalizeMethod centerMethod countMethod endswithMethod equalMethod expandtabsMethod findMethod greaterMethod greater_equalMethod indexMethod isalnumMethod isalphaMethod isdecimalMethod isdigitMethod isnumericMethod isupperMethod joinMethod lessMethod less_equalMethod ljustMethod lowerMethod multiplyMethod not_equalMethod rfindMethod rjustMethod rstripMethod splitMethod splitlinesMethod startswithMethod upperMethod zfill
0
0
0
new
NumPy | splitlines method
Programming
chevron_rightPython
chevron_rightNumPy
chevron_rightDocumentation
chevron_rightChar
schedule Mar 9, 2022
Last updated Python●NumPy
Tags tocTable of Contents
expand_more Numpy's splitlines(~)
method splits each string in the input array by line-break.
Parameters
1. a
| array-like
The input array whose strings you want converted to uppercase.
2. keepends
| boolean
| optional
Whether to include line-breaks. By default, keepends=False
.
Return Value
A Numpy array of lists that contain the strings separated by line-break.
Examples
Basic usage
np.char.splitlines(["ab\ncd", "a\nb\nc"])
array([list(['ab', 'cd']), list(['a', 'b', 'c'])], dtype=object)
Notice how the return value is a Numpy array of lists containing the partitioned strings.
Specifying Keepends
np.char.splitlines("ab\ncd", keepends=True)
array(list(['ab\n', 'cd']), dtype=object)
Notice how the line break \n
is kept.
Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
Ask a question or leave a feedback...