In [
1]: import numpy as np
...: a=np.array([
1,
2,
3,
4,
5,
6]).reshape(
2,
3).astype(
"str")
...: a
Out[
1]:
array([[
'1',
'2',
'3'],
[
'4',
'5',
'6']],
dtype=
'<U11')
In [
2]:
".".join(a[
0])
Out[
2]:
'1.2.3'
In [
3]: np.apply_along_axis(
"-".join,
1, a)
Out[
3]:
array([
'1-2-3',
'4-5-6'],
dtype=
'<U5')
转载请注明原文地址: https://www.6miu.com/read-9022.html