teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

文法の修正

2019/10/11 15:31

投稿

arupaka_910
arupaka_910

スコア6

title CHANGED
File without changes
body CHANGED
@@ -35,13 +35,11 @@
35
35
 
36
36
  ネットの対処方を試してみたのですが、結果は同じでした。
37
37
  ↓実行時のターミナル画面です。
38
-
38
+ (header=None追加後のエラー)
39
39
  Traceback (most recent call last):
40
- File "/Users/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/pandas/indexes/base.py", line 1986, in get_value
41
- return tslib.get_value_box(s, key)
42
- File "pandas/tslib.pyx", line 777, in pandas.tslib.get_value_box (pandas/tslib.c:17017)
40
+ File "pandas/index.pyx", line 159, in pandas.index.IndexEngine.get_loc (pandas/index.c:4018)
43
- File "pandas/tslib.pyx", line 786, in pandas.tslib.get_value_box (pandas/tslib.c:16691)
41
+ File "pandas/hashtable.pyx", line 303, in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6589)
44
- TypeError: 'str' object cannot be interpreted as an integer
42
+ TypeError: an integer is required
45
43
 
46
44
  During handling of the above exception, another exception occurred:
47
45
 
@@ -50,15 +48,12 @@
50
48
  malist = t.tokenize(rows['0'])
51
49
  File "/Users/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/pandas/core/series.py", line 583, in __getitem__
52
50
  result = self.index.get_value(self, key)
53
- File "/Users/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/pandas/indexes/base.py", line 1994, in get_value
54
- raise e1
55
51
  File "/Users/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/pandas/indexes/base.py", line 1980, in get_value
56
52
  tz=getattr(series.dtype, 'tz', None))
57
53
  File "pandas/index.pyx", line 103, in pandas.index.IndexEngine.get_value (pandas/index.c:3332)
58
54
  File "pandas/index.pyx", line 111, in pandas.index.IndexEngine.get_value (pandas/index.c:3035)
59
- File "pandas/index.pyx", line 159, in pandas.index.IndexEngine.get_loc (pandas/index.c:4018)
55
+ File "pandas/index.pyx", line 161, in pandas.index.IndexEngine.get_loc (pandas/index.c:4084)
60
- File "pandas/hashtable.pyx", line 675, in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:12368)
61
- File "pandas/hashtable.pyx", line 683, in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:12322)
62
56
  KeyError: '0'
63
57
 
58
+
64
59
  宜しくお願い致します。

1

文法修正

2019/10/11 15:31

投稿

arupaka_910
arupaka_910

スコア6

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,6 @@
1
1
  csvのデータからストップワード辞書を作るため、以下のサイトのソースコードをを参考に、プログラムを動かそうとしたのですが、KeyError: '0'というエラーが出てきましたた。csvデータはヘッダーなし5000行程度、3列という構成です。
2
2
 
3
- https://gukoulog.com/2018/10/07/python-4/ <<<参考サイトのURL
3
+ [リンク内容](https://gukoulog.com/2018/10/07/python-4/) <<<参考サイト
4
4
 
5
5
  ↓自身のソースコードです。
6
6
  ```ここに言語を入力
@@ -33,7 +33,32 @@
33
33
  print("finish")
34
34
  ```
35
35
 
36
+ ネットの対処方を試してみたのですが、結果は同じでした。
36
37
  ↓実行時のターミナル画面です。
38
+
37
- ネットの対象方を試してみたのですが、結果は同じでした。
39
+ Traceback (most recent call last):
40
+ File "/Users/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/pandas/indexes/base.py", line 1986, in get_value
41
+ return tslib.get_value_box(s, key)
42
+ File "pandas/tslib.pyx", line 777, in pandas.tslib.get_value_box (pandas/tslib.c:17017)
43
+ File "pandas/tslib.pyx", line 786, in pandas.tslib.get_value_box (pandas/tslib.c:16691)
44
+ TypeError: 'str' object cannot be interpreted as an integer
45
+
46
+ During handling of the above exception, another exception occurred:
47
+
48
+ Traceback (most recent call last):
49
+ File "/Users/Desktop/program/pro_code/CntWord_csv.py", line 13, in <module>
50
+ malist = t.tokenize(rows['0'])
51
+ File "/Users/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/pandas/core/series.py", line 583, in __getitem__
52
+ result = self.index.get_value(self, key)
53
+ File "/Users/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/pandas/indexes/base.py", line 1994, in get_value
54
+ raise e1
55
+ File "/Users/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/pandas/indexes/base.py", line 1980, in get_value
38
- ![イメージ説明](33d78ea19fe0a5d884b081055ed0c706.png)
56
+ tz=getattr(series.dtype, 'tz', None))
57
+ File "pandas/index.pyx", line 103, in pandas.index.IndexEngine.get_value (pandas/index.c:3332)
58
+ File "pandas/index.pyx", line 111, in pandas.index.IndexEngine.get_value (pandas/index.c:3035)
59
+ File "pandas/index.pyx", line 159, in pandas.index.IndexEngine.get_loc (pandas/index.c:4018)
60
+ File "pandas/hashtable.pyx", line 675, in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:12368)
61
+ File "pandas/hashtable.pyx", line 683, in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:12322)
62
+ KeyError: '0'
63
+
39
64
  宜しくお願い致します。