所以我是python的新手,使用pytrends时遇到了问题。我正在尝试比较5个搜索词并将总和存储在CSV中。
我现在遇到的问题是我似乎无法隔离返回的单个元素。我有数据,可以看到,但是我似乎无法隔离一个元素,以能够对它做任何有意义的事情。
我在其他地方找到了使用iloc的建议,但这并不会为显示的内容返回任何内容,如果我仅传递一个参数,它似乎会显示所有内容。
感觉真是愚蠢,但我只是想不通,也无法在网上找到任何东西。
from pytrends.request import TrendReq
import csv
import pandas
import numpy
import time
# Login to Google. Only need to run this once, the rest of requests will use the same session.
pytrend = TrendReq(hl='en-US', tz=360)
with open('database.csv',"r") as f:
reader = csv.reader(f,delimiter = ",")
data = list(reader)
row_count = len(data)
comparator_string = data[1][0] + " opening"
print("comparator: ",comparator_string,"\n")
#Initialize search term list including comparator_string as the first item, plus 4 search terms
kw_list=[]
kw_list.append(comparator_string)
for x …
Run Code Online (Sandbox Code Playgroud)