取得した文字列のリストをpandasに入れたい
ここに質問の内容を詳しく書いてください。
pythonで言語処理の学習をしております。
学習の過程で文字列のリストをpandasに渡したのですがそこでエラーをはかれてしまいました。
カラム部分をどういじればいいのかわかりません。よろしくお願いします。
発生している問題・エラーメッセージ
AssertionError: 3 columns passed, passed data had 2 columns
該当のソースコード
python
1import tweepy 2import pickle 3import pandas as pd 4 5CONSUMER_KEY="xxxxxxxxxxxxxxxxxxxxxx" 6CONSUMER_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxx" 7ACCESS_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 8ACCESS_TOKEN_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 9 10auth=tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET) 11auth.set_access_token(ACCESS_TOKEN,ACCESS_TOKEN_SECRET) 12 13api=tweepy.API(auth) 14 15f=open("omoshiro_data.txt","w") 16 17omoro_list=[] 18 19for tweet in tweepy.Cursor(api.user_timeline,screen_name="omoshiro_senryu",exclude_replies=True).items(): 20 text=tweet.text 21 omoro_list.append(text) 22 for omoro in omoro_list: 23 test=omoro.split() 24 if len(test)>=5: 25 del test[4:] 26 if len(test)==4: 27 del test[3] 28 df=pd.DataFrame([test],columns=["A","B","C"]) 29 30print(df) 31
###試したこと
カラムの追加等。
回答1件
あなたの回答
tips
プレビュー