Panda AssertionError columns passed, passed data had 2 columns

有些话、适合烂在心里 提交于 2019-12-06 05:19:23

问题


I am working on Azure ML implementation on text analytics with NLTK, the following execution is throwing

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

Below is the code

# 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]

Error is throwing here

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

I suspect this to be the tagged data type passed to dataframe, can some one let me know the right approach to add this to dataframe.


回答1:


Try this:

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


来源:https://stackoverflow.com/questions/38927230/panda-assertionerror-columns-passed-passed-data-had-2-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!