This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
import matplotlib.pyplot as plt | |
G = nx.read_graphml("football_network.graphml") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
retorno = get_tunnel() | |
print(retorno) | |
!python my_dash_app.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
download_ngrok() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%writefile my_dash_app.py | |
import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
import plotly.express as px | |
import pandas as pd | |
import numpy as np | |
import json | |
from dash.dependencies import Input, Output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig = px.scatter_mapbox(df, | |
lat='centroid_lat', | |
lon='centroid_lon', | |
text='text', | |
size='approxim', | |
size_max=40, | |
zoom=15, | |
mapbox_style='carto-positron') | |
fig.update_layout(margin={'r':0,'t':0,'l':0,'b':0}) | |
fig.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dataset example | |
df = pd.DataFrame(data={'centroid_lat':[48.858412], | |
'centroid_lon':[2.294492], | |
'approxim':[50], | |
'text':['Torre Eiffel']}) | |
df |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Response = namedtuple('Response', ['url', 'error']) | |
def get_tunnel(): | |
try: | |
Tunnel = subprocess.Popen(['./ngrok','http','8050']) | |
session = requests.Session() | |
retry = Retry(connect=3, backoff_factor=0.5) | |
adapter = HTTPAdapter(max_retries=retry) | |
session.mount('http://', adapter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def download_ngrok(): | |
if not os.path.isfile('ngrok'): | |
!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip | |
!unzip -o ngrok-stable-linux-amd64.zip | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path | |
import sys, json | |
import requests | |
import subprocess | |
import numpy as np | |
import pandas as pd | |
import plotly.express as px | |
from requests.exceptions import RequestException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Plotly | |
!pip install Plotly==4.12 | |
# Install Dash | |
!pip install dash | |
!pip install dash-html-components | |
!pip install dash-core-components | |
!pip install dash-table |