Search icon CANCEL
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
Extending Power BI with Python and R

You're reading from   Extending Power BI with Python and R Ingest, transform, enrich, and visualize data using the power of analytical languages

Arrow left icon
Product type Paperback
Published in Nov 2021
Publisher Packt
ISBN-13 9781801078207
Length 558 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Luca Zavarella Luca Zavarella
Author Profile Icon Luca Zavarella
Luca Zavarella
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Preface 1. Section 1: Best Practices for Using R and Python in Power BI
2. Chapter 1: Where and How to Use R and Python Scripts in Power BI FREE CHAPTER 3. Chapter 2: Configuring R with Power BI 4. Chapter 3: Configuring Python with Power BI 5. Section 2: Data Ingestion and Transformation with R and Python in Power BI
6. Chapter 4: Importing Unhandled Data Objects 7. Chapter 5: Using Regular Expressions in Power BI 8. Chapter 6: Anonymizing and Pseudonymizing Your Data in Power BI 9. Chapter 7: Logging Data from Power BI to External Sources 10. Chapter 8: Loading Large Datasets beyond the Available RAM in Power BI 11. Section 3: Data Enrichment with R and Python in Power BI
12. Chapter 9: Calling External APIs to Enrich Your Data 13. Chapter 10: Calculating Columns Using Complex Algorithms 14. Chapter 11: Adding Statistics Insights: Associations 15. Chapter 12: Adding Statistics Insights: Outliers and Missing Values 16. Chapter 13: Using Machine Learning without Premium or Embedded Capacity 17. Section 3: Data Visualization with R in Power BI
18. Chapter 14: Exploratory Data Analysis 19. Chapter 15: Advanced Visualizations 20. Chapter 16: Interactive R Custom Visuals 21. Other Books You May Enjoy

Implementing distances using Python

The scenario on which we will implement the distance algorithms just described involves a dataset of US hotels, containing the latitude and longitude of each. The goal is to enrich the dataset by adding the distances to the nearest airports.

The hotel data is publicly available on Back4App (https://bit.ly/data-hotels-usa). For convenience, we extracted only 100 hotels from New York City and we will calculate for each of them the distances from the LaGuardia and John F. Kennedy airports (you can find the airport data here: https://datahub.io/core/airport-codes) using the Haversine (spherical model) and Karney (ellipsoidal model) methods. You can find the already extracted datasets for your convenience in the Chapter10 folder of the GitHub repository. In detail, you will find the hotel data in the hotels-ny.xlsx file and the airport data in the airport-codes.csv file.

Calculating distances with Python

As we mentioned earlier, we are not those...

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 £16.99/month. Cancel anytime