非常に基礎的な内容ですが、解決できないのでお願いします
python
1 2import numpy as np 3import math 4filepath = r'C:\Users\yes\Desktop' 5f = filepath + '\' + 'long100-300nonnormalizedresult(Ch.1).csv' 6 7event = np.loadtxt(f, dtype=np.str, delimiter='/t', skiprows=(1), usecols=(1) ) 8 9print(event)
このように入力したのですが、usecolsをloadtxtの因数に含めるとエラーが出てしまいます。(IndexError: list index out of range)このようなエラーです。なぜこのようなエラーが出るのか教えて下さい。エクセルファイルの二行目だけほしいので、このような引数を利用しています。以下、エラー文です。
IndexError Traceback (most recent call last)
<ipython-input-31-55a2b9006923> in <module>
4 f = filepath + '' + 'long100-300nonnormalizedresult(Ch.1).csv'
5
----> 6 event = np.loadtxt(f, dtype=np.str, delimiter='/t', skiprows=(1), usecols=(1) )
7
8 print(event)
~\Anaconda3\lib\site-packages\numpy\lib\npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding)
1099 # converting the data
1100 X = None
-> 1101 for x in read_data(_loadtxt_chunksize):
1102 if X is None:
1103 X = np.array(x, dtype)
~\Anaconda3\lib\site-packages\numpy\lib\npyio.py in read_data(chunk_size)
1019 continue
1020 if usecols:
-> 1021 vals = [vals[j] for j in usecols]
1022 if len(vals) != N:
1023 line_num = i + skiprows + 1
~\Anaconda3\lib\site-packages\numpy\lib\npyio.py in <listcomp>(.0)
1019 continue
1020 if usecols:
-> 1021 vals = [vals[j] for j in usecols]
1022 if len(vals) != N:
1023 line_num = i + skiprows + 1
IndexError: list index out of range
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/10 07:54
2020/01/10 07:55
2020/01/10 08:06
2020/01/10 08:10
2020/01/10 08:15
2020/01/10 08:17
2020/01/10 08:23 編集
2020/01/10 08:43
2020/01/10 08:47