{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import folium\n",
"import warnings\n",
"import pandas as pd \n",
"import plotly.express as px\n",
"import matplotlib.pyplot as plt\n",
"import plotly.graph_objects as go\n",
"\n",
"from difflib import get_close_matches\n",
"from plotly.subplots import make_subplots\n",
"\n",
"plt.style.use('ggplot')\n",
"warnings.filterwarnings(\"ignore\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Read and clean up data \n",
"\n",
"Remove nans value and replace them from: latitude country, longitude_country, country, city, gdp_country."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('data.csv')\n",
"\n",
"df.latitude_country = df.latitude_country.fillna(0.0)\n",
"df.longitude_country = df.longitude_country.fillna(0.0)\n",
"df.country = df.country.fillna('Unknown')\n",
"df.city = df.city.fillna('Unknown')\n",
"df.gdp_country = df.gdp_country.fillna(0.0)\n",
"df.finalWorth = df.finalWorth / 1000"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Interactive plots using plotly"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Plot made using ploty that dipslay on hover age, net worth and name of billionaire"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"customdata": [
[
"Bernard Arnault & family"
],
[
"Elon Musk"
],
[
"Jeff Bezos"
],
[
"Larry Ellison"
],
[
"Warren Buffett"
],
[
"Bill Gates"
],
[
"Michael Bloomberg"
],
[
"Carlos Slim Helu & family"
],
[
"Mukesh Ambani"
],
[
"Steve Ballmer"
],
[
"Francoise Bettencourt Meyers & family"
],
[
"Larry Page"
],
[
"Amancio Ortega"
],
[
"Sergey Brin"
],
[
"Zhong Shanshan"
],
[
"Mark Zuckerberg"
],
[
"Charles Koch & family"
],
[
"Julia Koch & family"
],
[
"Jim Walton"
],
[
"Rob Walton & family"
]
],
"hovertemplate": "age=%{marker.color}
finalWorth=%{marker.size}
personName=%{customdata[0]}