小编sus*_*sim的帖子

python pandas数据帧写多行标题

数据1

A  B  C  D  E   <--- columns
a  b  c  d  e
a  b  c  d  e
a  b  c  d  e


result what i want

A  B  C  D  E <--- columns
A  B  C  D  E <--- columns
A  B  C  D  E <--- columns
a  b  c  d  e
a  b  c  d  e
a  b  c  d  e
Run Code Online (Sandbox Code Playgroud)

我搜索了这个,但最终失败了:)

我如何获得好的结果?我请求你的帮助。谢谢你


非常感谢

转换为 Excel 时,创建了一个新的空列。

test

a   b   c   d   e   f   g   h   i   j …
Run Code Online (Sandbox Code Playgroud)

dataframe pandas pandas.excelwriter

3
推荐指数
1
解决办法
4706
查看次数

NLTK Lemmatizer,提取有意义的词

目前,我将创建一个基于机器学习的自动映射类别的代码。

在那之前我会做自然语言处理。

有几个单词列表。

      sent ='The laughs you two heard were triggered 
             by memories of his own high j-flying 
             moist moisture moisturize moisturizing '.lower().split()
Run Code Online (Sandbox Code Playgroud)

我做了以下代码。我参考了这个网址。NLTK:词形还原器和 pos_tag

from nltk.tag import pos_tag
from nltk.tokenize import word_tokenize
from nltk.stem import WordNetLemmatizer
def lemmatize_all(sentence):
    wnl = WordNetLemmatizer()
    for word, tag in pos_tag(word_tokenize(sentence)):
        if tag.startswith("NN"):
            yield wnl.lemmatize(word, pos='n')
        elif tag.startswith('VB'):
            yield wnl.lemmatize(word, pos='v')
        elif tag.startswith('JJ'):
            yield wnl.lemmatize(word, pos='a')



words = ' '.join(lemmatize_all(' '.join(sent)))
Run Code Online (Sandbox Code Playgroud)

结果值如下所示。

laugh heard be trigger memory own high j-flying moist moisture moisturize …
Run Code Online (Sandbox Code Playgroud)

nlp nltk lemmatization python-3.x

0
推荐指数
1
解决办法
2313
查看次数