Closed asdsadsaasd12312132 closed 11 months ago
This might be an issue with pytrends.
Hi, thanks for the issue. Please can you copy your exact code here, and second keyword? I'll see if I can reproduce. In the meantime, I just ran this with no issue:
from datetime import datetime
import matplotlib.pyplot as plt
from longtrends import rescale_overlaps, get_overlapping_trends, rescaled_longtrend
import pandas as pd
keyword = 'suncream'
overlapping = get_overlapping_trends(
keyword=keyword,
start_date=datetime(2018, 1, 1),
end_date=datetime(2022, 3, 31),
verbose=True)
pd.concat(overlapping, axis=1).plot(figsize=(15,3), legend=False)
rescaled = rescale_overlaps(overlapping)
pd.concat(rescaled, axis=1).plot(figsize=(15,3), legend=False)
rescaled = rescaled_longtrend(rescaled)
rescaled.plot(figsize=(15,3), title='Rescaled long-term trend')
plt.show()
Thanks for the info on issues with pytrends. Possibly the results depend on where you are geographically. If you give me your code I'll try and run it here in the UK.
I tried that code and it works, but I have an issue with many 0 values. Do you have this problem too? My location is Australia.
The code I was trying before stopped giving errors but no chart appears after successfully running it.
from longtrends import LongTrend
from datetime import datetime
keyword = 'suncream'
# Create LongTrend object
longtrend = LongTrend(
keyword=keyword,
start_date=datetime(2018, 1, 1),
end_date=datetime(2022, 3, 31)) # use verbose=True for print output
# Build long-term trends
lt_built = longtrend.build()
# Plot
lt_built.plot(title=f"Google Trends: {longtrend.keyword}", figsize=(15, 3))
Hello there,
I am experiencing the same problem. My location is South Africa.
Thanks both, this seems to be an ongoing underlying issue with pytrends. Closing for now, since the issue is not with longtrends.
@asdsadsaasd12312132 , regarding this:
The code I was trying before stopped giving errors but no chart appears after successfully running it.
Make sure you pip install matplotlib
and import matplotlib.pyplot as plt
I used the sample code provided and get this error.
When I change the keyword, I get this error.