a=["And","I","love","her"]
b=" ".join(a)
print b
Execution result:
'And I love her'
import numpy as np
np.core.defchararray.split(np.array(b))
Execution result:
array(['And,', 'I', 'love', 'her'], dtype=object)
Here, tag = ['svd3''svd3''svd3''svd3''svd5''svd5''svd5''svd3''svd3''svd3' I want to add the word
" iseg "to the end of each element of the ndarray called'svd3']
import numpy as np
num=len(tag)
iseg= np.array(["iseg"]*num)
tag=np.core.defchararray.add(tag,iseg)
print tag
Execution result:
['svd3iseg' 'svd3iseg' 'svd3iseg' 'svd3iseg' 'svd5iseg' 'svd5iseg'
'svd5iseg' 'svd3iseg' 'svd3iseg' 'svd3iseg' 'svd3iseg']
a=["1.0","2","4.e-3"]
map(float,a)
result:
[1.0, 2.0, 0.004]
b=[1.0, 2.0, 0.004]
map(str,a)
result:
['1.0', '2', '4.e-3']
val. isdigit()
It's awkward for floats
val.replace(".","",1).isdigit()
For details, refer to http://d.hatena.ne.jp/artgear/20120217/1329493335 etc.
Recommended Posts