在将pandas系列转换为字符串时未获得所需的输出

时间:2017-06-28 08:13:34

标签: python pandas

使用下面的代码时,我只获得整个列的单个输出。但我想要每行的输出。我想知道我该怎么做?这是我从数据框转换的字符串。

from textblob.classifiers import DecisionTreeClassifier

train = [('I love this sandwich.', 'pos'),
        ('This is an amazing place!', 'pos'),
        ('I feel very good about these beers.', 'pos'),
        ('I do not like this restaurant', 'neg'),
        ('I am tired of this stuff.', 'neg'),
        ("I can't deal with this", 'neg'),
        ("My boss is horrible.", "neg")
    ]
ho=tweets['twt'] % where tweets['twt'] contains tweets in text format
a=ho.to_string(buf=None, columns=None, col_space=None, header=True, index=True, na_rep='NaN', formatters=None, float_format=None, sparsify=False, index_names=True, justify=None, line_width=None, max_rows=None, max_cols=None, show_dimensions=False)

cl = DecisionTreeClassifier(train)        
blob = TextBlob(a, classifier=cl)
for s in blob.sentences:
    print(s)
    print(s.classify())

当前输出: - enter image description here

0 个答案:

没有答案