numpy.defchararray.add() in Python
numpy.core.defchararray.add(arr1, arr2): Concatenates two strings element-wise.
Parameters:
arr1 : array-like or string.
arr2 : array-like or string.Returns : Concatenates String.
Code #1:
# Python Program illustrating # numpy.char.add() method import numpy as np arr1 = ['vdteteAAAa', 'AAAttttds', 'AAaxtt'] arr2 = ['1111sfdsf', '1111111sdsf2', '1111111sfsf2'] print ("\narr1 : ", arr1) print ("\narr2 : ", arr2) print ("\narr1 + arr2\n", np.char.add(arr1, arr2)) print ("\narr2 + arr1\n", np.char.add(arr2, arr1)) |
chevron_right
filter_none
Output:
arr1 : ['vdteteAAAa', 'AAAttttds', 'AAaxtt'] arr2 : ['1111sfdsf', '1111111sdsf2', '1111111sfsf2'] arr1 + arr2 ['vdteteAAAa1111sfdsf' 'AAAttttds1111111sdsf2' 'AAaxtt1111111sfsf2'] arr2 + arr1 ['1111sfdsfvdteteAAAa' '1111111sdsf2AAAttttds' '1111111sfsf2AAaxtt']
Code #2:
# Python Program illustrating # numpy.char.add() method import numpy as np arr1 = 'This is geeks 'arr2 = 'for geeks ' print ("\narr1 + arr2\n", np.char.add(arr1, arr2)) print ("\narr2 + arr1\n", np.char.add(arr2, arr1)) |
chevron_right
filter_none
Output:
arr1 + arr2 This is geeks for geeks arr2 + arr1 for geeks This is geeks
Recommended Posts:
- Python | Convert list to Python array
- Python | Index of Non-Zero elements in Python list
- Important differences between Python 2.x and Python 3.x with examples
- Reading Python File-Like Objects from C | Python
- Python | Merge Python key values to list
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Visualizing O(n) using Python
- JavaScript vs Python : Can Python Overtop JavaScript by 2020?
- Any & All in Python
- SQL using Python | Set 1
- set add() in python
- chr() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



