gpt4 book ai didi

python - Panda AssertionError 列已传递,传递的数据有 2 列

转载 作者:行者123 更新时间:2023-12-02 09:14:46 24 4
gpt4 key购买 nike

我正在使用 NLTK 进行文本分析的 Azure ML 实现,以下执行抛出异常

AssertionError: 1 columns passed, passed data had 2 columns\r\nProcess returned with non-zero exit code 1

下面是代码

# The script MUST include the following function,
# which is the entry point for this module:
# Param<dataframe1>: a pandas.DataFrame
# Param<dataframe2>: a pandas.DataFrame
def azureml_main(dataframe1 = None, dataframe2 = None):
# import required packages
import pandas as pd
import nltk
import numpy as np
# tokenize the review text and store the word corpus
word_dict = {}
token_list = []
nltk.download(info_or_id='punkt', download_dir='C:/users/client/nltk_data')
nltk.download(info_or_id='maxent_treebank_pos_tagger', download_dir='C:/users/client/nltk_data')
for text in dataframe1["tweet_text"]:
tokens = nltk.word_tokenize(text.decode('utf8'))
tagged = nltk.pos_tag(tokens)


# convert feature vector to dataframe object
dataframe_output = pd.DataFrame(tagged, columns=['Output'])
return [dataframe_output]

这里抛出错误

 dataframe_output = pd.DataFrame(tagged, columns=['Output'])

我怀疑这是传递给数据帧的标记数据类型,有人可以让我知道将其添加到数据帧的正确方法吗?

最佳答案

试试这个:

dataframe_output = pd.DataFrame(tagged, columns=['Output', 'temp'])

关于python - Panda AssertionError 列已传递,传递的数据有 2 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38927230/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com