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
# Read the data | |
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/US-shooting-incidents.csv") | |
# Let us only take 10 samples | |
df = df.sample(10) | |
# One width for all | |
pn.widgets.Tabulator(df, widths=130) | |
# Automatically adjust the columns dependending on their content |
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
formatters = { | |
'latitude': {'type': 'progress', 'max': 90.00, 'color':'red'}, | |
'longitude': {'type': 'progress', 'max': 180.00}, | |
'large': {'type': 'tickCross'}, | |
} | |
pn.widgets.Tabulator(df, formatters=formatters) |
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
from bokeh.models.widgets.tables import NumberFormatter, BooleanFormatter | |
bokeh_formatters = { | |
'latitude': NumberFormatter(format='0.00'), | |
'large': BooleanFormatter(), | |
} | |
pn.widgets.Tabulator(df, formatters=bokeh_formatters) |
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 datetime as dt | |
import numpy as np | |
import pandas as pd | |
import panel as pn | |
pn.extension('tabulator') | |
df = pd.DataFrame({ | |
'city': ["A", "B", "C", "D", "E"], | |
'latitude': [34.6578, 76.6789, 23.7896, 45.6785, 14.2545], |
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 streamlit as st | |
import PIL | |
from exif import Image | |
from collections import defaultdict | |
import pandas as pd | |
st.set_page_config(page_title="Geolocating Photos Application", | |
page_icon="🌍", | |
layout="wide", | |
initial_sidebar_state="expanded") |
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 streamlit as st | |
import PIL | |
from exif import Image | |
from collections import defaultdict | |
st.set_page_config(page_title="Geolocating Photos Application", | |
page_icon="🌍", | |
layout="wide", | |
initial_sidebar_state="expanded") |
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 streamlit as st | |
import PIL | |
from exif import Image | |
st.set_page_config(page_title="Geolocating Photos Application", | |
page_icon="🌍", | |
layout="wide", | |
initial_sidebar_state="expanded") | |
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 streamlit as st | |
import PIL | |
st.set_page_config(page_title="Geolocating Photos Application", | |
page_icon="🌍", | |
layout="wide", | |
initial_sidebar_state="expanded") | |
st.sidebar.title("Geolocating Photos Application") |
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
@st.cache(persist=True, suppress_st_warning=True) | |
def display_map(df): | |
px.set_mapbox_access_token( | |
"pk.eyJ1Ijoic2hha2Fzb20iLCJhIjoiY2plMWg1NGFpMXZ5NjJxbjhlM2ttN3AwbiJ9.RtGYHmreKiyBfHuElgYq_w" | |
) | |
fig = px.scatter_mapbox(df, lat="latitude", lon="longitude", zoom=10) | |
return fig | |
def download_csv(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
def geocode(df): | |
locator = Nominatim(user_agent="myGeocoder") | |
geocode = RateLimiter(locator.geocode, min_delay_seconds=1) | |
df["location"] = df["geocode_col"].apply(geocode) | |
df["point"] = df["location"].apply(lambda loc: tuple(loc.point) if loc else None) | |
df[["latitude", "longitude", "altitude"]] = pd.DataFrame( | |
df["point"].tolist(), index=df.index | |
) | |
return df |
NewerOlder