沿轴错误的Python numpy sum

时间:2018-03-17 00:38:51

标签: python numpy sum

def tfdif(docs,normalize)
    docs_tokens = {idx: get_doc_tokens(doc, normalize) for idx, doc in enumerate(docs)}
    dtm = pd.DataFrame.from_dict(docs_tokens, orient="index")
    dtm = dtm.fillna(0)
    tf = dtm.values
    **doc_len = tf.sum(axis=1)**
tfidf(docs, 'stem')

**我收到此错误,我无法弄明白

  

追踪(最近的呼叫最后):
    文件" C:/ Users / Atiq / Documents / CS / BIA 660 / Assignment 5 / Assignment 5.py",第91行,< module>
      tfidf(docs,' stem')
    文件" C:/ Users / Atiq / Documents / CS / BIA 660 / Assignment 5 / Assignment 5.py",第51行,在tfidf中       doc_len = tf.sum(axis = 1)
    文件" C:\ Users \ Atiq \ PycharmProjects \ Trail \ venv \ lib \ site-packages \ numpy \ core_methods.py",第32行,在_sum中       return umr_sum(a,axis,dtype,out,keepdims)
  TypeError:必须是str,而不是int **

0 个答案:

没有答案