Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase speed? #5

Open
asdsadsaasd12312132 opened this issue Dec 12, 2023 · 4 comments
Open

Increase speed? #5

asdsadsaasd12312132 opened this issue Dec 12, 2023 · 4 comments

Comments

@asdsadsaasd12312132
Copy link

The script is taking 10 minutes to chart 2 years of data, which is too long. Is there any way to speed it up?

@mikedbjones
Copy link
Owner

Can you be any more specific? Code, keywords, environment, hardware, etc? This code normally takes a matter of seconds, so I imagine there is an external factor that's causing the long runtime, in which case I'll be unable to assist.

@asdsadsaasd12312132
Copy link
Author

asdsadsaasd12312132 commented Dec 13, 2023

This is my code. It tooks long for every keyword I use. I'm on WIndows 10 64 bit. My hardware should be strong enough. I have the latest i9 and 64 gb of RAM.

from longtrends import LongTrend
from datetime import date, datetime, timedelta
import matplotlib.pyplot as plt
import mplcursors
from matplotlib.widgets import Cursor

keyword = 'apples'

# Create LongTrend object
longtrend = LongTrend(
                      keyword=keyword,
                      start_date=datetime(2022, 1, 1),
                      end_date=datetime.now())        # use verbose=True for print output
# Build long-term trends
lt_built = longtrend.build()

# Plot
axlist = lt_built.plot(title=f"Google Trends: {longtrend.keyword}", figsize=(15, 3))
mplcursors.cursor(axlist) #annotation when clicking on point
cursor = Cursor(axlist, useblit=True, color='k', lw=0.6, ls='--') #crosshair

plt.show()

I have also issues where some parts of the chart are flat.

image

@mikedbjones
Copy link
Owner

I recommend you use some python timing functions to narrow down the problem. Ultimately, since longtrends simply scales pytrends outputs, the timing issue is likely to be with pytrends, or your plotting library. Without detailed information I cannot assist further.

@asdsadsaasd12312132
Copy link
Author

You said it only takes a few seconds for you. What code were you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants