Python numpy沿轴求和

2024-09-30 01:24:14 发布

您现在位置:Python中文网/ 问答频道 /正文

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')

**我得到这个错误,我无法找出

Traceback (most recent call last):
File "C:/Users/Atiq/Documents/CS/BIA 660/Assignment 5/Assignment 5.py", line 91, in <module>
tfidf(docs, 'stem')
File "C:/Users/Atiq/Documents/CS/BIA 660/Assignment 5/Assignment 5.py", line 51, in tfidf
doc_len = tf.sum(axis=1)
File "C:\Users\Atiq\PycharmProjects\Trail\venv\lib\site-packages\numpy\core_methods.py", line 32, in _sum
return umr_sum(a, axis, dtype, out, keepdims)
TypeError: must be str, not int**


Tags: inpydocsdoctflineusersfile

热门问题