Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Art of Data-Driven Business

You're reading from   The Art of Data-Driven Business Transform your organization into a data-driven one with the power of Python machine learning

Arrow left icon
Product type Paperback
Published in Dec 2022
Publisher Packt
ISBN-13 9781804611036
Length 314 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Alan Bernardo Palacio Alan Bernardo Palacio
Author Profile Icon Alan Bernardo Palacio
Alan Bernardo Palacio
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Part 1: Data Analytics and Forecasting with Python
2. Chapter 1: Analyzing and Visualizing Data with Python FREE CHAPTER 3. Chapter 2: Using Machine Learning in Business Operations 4. Part 2: Market and Customer Insights
5. Chapter 3: Finding Business Opportunities with Market Insights 6. Chapter 4: Understanding Customer Preferences with Conjoint Analysis 7. Chapter 5: Selecting the Optimal Price with Price Demand Elasticity 8. Chapter 6: Product Recommendation 9. Part 3: Operation and Pricing Optimization
10. Chapter 7: Predicting Customer Churn 11. Chapter 8: Grouping Users with Customer Segmentation 12. Chapter 9: Using Historical Markdown Data to Predict Sales 13. Chapter 10: Web Analytics Optimization 14. Chapter 11: Creating a Data-Driven Culture in Business 15. Index 16. Other Books You May Enjoy

Finding changes in search trend patterns

Search trends are not a static variable; in fact, they change and vary over time. We will get the results of the interest by region in the last 3 months and then we will look at changes in the results compared to the ones obtained over a period of 12 months:

  1. To find the changes in search trends patterns, we will build the payload within a different timeframe.
  2. Finally, we will store the results in a pandas DataFrame named regiondf_3m:
    #search interest per region
    pytrend = TrendReq()
    pytrend.build_payload(kw_list, timeframe='today 3-m')
    # Interest by Region
    regiondf_3m = pytrend.interest_by_region()
  3. We need to remove the rows that don’t have results for the search terms specified:
    # #looking at rows where all values are not equal to 0
    regiondf_3m = regiondf_3m[regiondf_3m.sum(axis=1)!=0]
  4. Now, we can visualize the results using the plot method of the pandas DataFrame:
    # visualize
    regiondf_3m.plot(figsize=(14, 8), y=kw_list...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime