with open('path') as f:
a = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
b = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
c = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
d = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
e = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
f = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
g = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
h = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
i = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
j = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
k = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
l = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
m = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
n = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
o = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
with open('path') as f:
p = [list(map(lambda x:int(x), i.split())) for i in f.read().splitlines()]
q=np.stack([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p],0)
paθの部分は自分のパソコンのファイルを開くためのpathになっています。
このようにJupyterで複数の2次元配列のテキストファイルを開いて、stackで3次元配列にしたいのですが、
all input arrays must have the same shape
というエラーが出て、3次元配列にすることができません。
a~pまで1つずつ試したところ、6個目のfのテキストファイルのみ3次元配列にできないです。
テキストファイルの2次元配列は全て大きさが同じなので、なぜこのように出てしまうのかわかる方いらっしゃったら教えていただきたいです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/02/15 14:01