次の形式のファイル data.dat にデータがあります。
column_1 col col col col col
1 2 3 1 2 3
4 3 2 3 2 4
1 4 3 1 4 3
5 6 4 5 6 4
そして、列名 col を持つすべてのデータが変数 y に格納されるように、np.genfromtxt を使用してインポートしようとしています。コードを使用して試しました:
import numpy as np
data = np.genfromtxt('data.dat', comments='#', delimiter='\t', dtype=None, names=True).transpose()
y = data['col']
しかし、それは私に次のエラーを与えます:
ValueError: two fields with the same name
これはPythonでどのように解決できますか?