I've locked myself out of pytrends trying to solve this. Found some help in an old post
There are a few elements, firstly, I don't fully understand the documentation e.g. what is the payload? When i run it it doesn't seem to do anything. The result is I'm working with a lot of copy pasted code.
Second, I want to get keyword trend data for the year to date in a .csv
import pandas as pd
from pytrends.exceptions import ResponseError
from pytrends.request import TrendReq
import matplotlib.pyplot as plt
data = []
kw_list = ["maxi dresses", "black shorts"]
for kw in kw_list:
kw_data = dailydata.get_daily_data(kw, 2020, 1, 2020, 4, geo = 'GB')
data.append(kw_data)
data.to_csv(r"C:\Users\XXXX XXXXX\Documents\Python Files\PyTrends\trends_py.csv".)
I also tried:
df =pytrends.get_historical_interest(kw_list, year_start=2020, month_start=1, day_start=1, year_end=2020, month_end=4, geo='GB', gprop='', sleep=0)
df = df.reset_index()
df.head(20)
Though for my purposes get_historical_interest
is useless because it provides hourly data with lots of 0s. The hourly data also doesn't match trends.