Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Interactive Data Visualization with Python

You're reading from   Interactive Data Visualization with Python Present your data as an effective and compelling story

Arrow left icon
Product type Paperback
Published in Apr 2020
Publisher
ISBN-13 9781800200944
Length 362 pages
Edition 2nd Edition
Languages
Arrow right icon
Authors (4):
Arrow left icon
Shubhangi Hora Shubhangi Hora
Author Profile Icon Shubhangi Hora
Shubhangi Hora
Abha Belorkar Abha Belorkar
Author Profile Icon Abha Belorkar
Abha Belorkar
Anshu Kumar Anshu Kumar
Author Profile Icon Anshu Kumar
Anshu Kumar
Sharath Chandra Guntuku Sharath Chandra Guntuku
Author Profile Icon Sharath Chandra Guntuku
Sharath Chandra Guntuku
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Introduction to Visualization with Python – Basic and Customized Plotting 2. Static Visualization – Global Patterns and Summary Statistics FREE CHAPTER 3. From Static to Interactive Visualization 4. Interactive Visualization of Data across Strata 5. Interactive Visualization of Data across Time 6. Interactive Visualization of Geographical Data 7. Avoiding Common Pitfalls to Create Interactive Visualizations Appendix

3. From Static to Interactive Visualization

Activity 3: Creating Different Interactive Visualizations Using Plotly Express

Solution

  1. Open a new Jupyter notebook.
  2. Import the necessary Python libraries and packages:
    import pandas as pd
    import plotly.express as px
  3. Recreate the carbon dioxide emissions and GDP DataFrame from Exercise 22 in this notebook:
    url_co2 = 'https://raw.githubusercontent.com/TrainingByPackt/Interactive-Data-Visualization-with-Python/master/datasets/co2.csv'
    url_gm = 'https://raw.githubusercontent.com/TrainingByPackt/Interactive-Data-Visualization-with-Python/master/datasets/gapminder.csv'
    co2 = pd.read_csv(url_co2)
    gm = pd.read_csv(url_gm)
    df_gm = gm[['Country', 'region']].drop_duplicates()
    df_w_regions = pd.merge(co2, df_gm, left_on='country', right_on='Country', how='inner')
    df_w_regions = df_w_regions.drop('Country', axis='columns')
    new_co2 = pd.melt(df_w_regions...
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
Banner background image