I am trying to put my interactive jupyter notebook which uses pytrends on binder. When I run the interactive cells in the notebook, the correct output is produced. But, when I upload it to Binder, and run through it, the output is not correct. I made sure the notebook is up to date in my github repository, but it doesn’t seem to be updating in Binder.
Would appreciate any help on how to fix this.
Thanks.
Hi! If you share a link to your repository someone might be able to help.
You are not pinning any of your packages in your requirements.txt
file. I wonder if Binder is installing different versions of those packages compared to what you have locally and that is why the answers are different? See these docs on using pip freeze
pip freeze - pip documentation v21.1.2
I pinned the packages, but it still isn’t working the same as it is locally
What are the differences though you are seeing? What isn’t ‘correct’? Or not the same as local? I run it and get plots of trends, and so it seems the basics all work. You have to help us help you by explaining what we uninformed users should be picking up on.
I wonder if it is because you are getting results from different places in the world via Binder, depending on where MyBinder sends you?
Plus differences from Google Trends and differences between queries seems to be a thing, see examples:
- Pytrends trend results not similar with manually downloaded data
- Why is data downloaded via pytrends drastically different from using the Google Trends site?
- Different result from google trends: pytrends open issue #351
- Interest Over Time returns different values if run on hosted server: pytrends open issue #473
- Interest by region seems to return different values on the same request sent a few mins apart: pytrends closed issue #348
- Completely different results depending on the location?: google-trends-api open issue #147
The issue is that when I run a search with related terms as rising related queries or top related queries on Binder, the names that are used to produce the graphs do not match the Google Trends rising related queries or top related queries (can be seen by scrolling to the bottom on Google Trends site after a search). When I run it in jupyter notebook, the output does match the Google Trends site.
Also, the graphs are based on worldwide searches, so I don’t think it is because I am getting results from different places in the world.
I also don’t think it is an issue with Pytrends since it works locally.
What you are reporting seems to mirror a couple of the issues I posted about. Specifically:
- Different result from google trends: pytrends open issue #351
- Completely different results depending on the location?: google-trends-api open issue #147
There’s sampling going on even if it is worldwide. The Google documentation makes that clear. However it all works, I think you are seeing differences in data provided from Google’s side and not because the the different Binder severs in the world are running the code any different from your local machine.