SENCE 2025 Examples¶
In [1]:
Copied!
import insel
insel.block('sum', 2, 3)
import insel
insel.block('sum', 2, 3)
Out[1]:
5.0
In [2]:
Copied!
insel.block('do', parameters=[1, 10, 1])
[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
insel.block('do', parameters=[1, 10, 1])
[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
Out[2]:
[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
In [3]:
Copied!
insel.block('gain', 2, 5, 7, parameters=[3], outputs=3)
[6.0, 15.0, 21.0]
insel.block('gain', 2, 5, 7, parameters=[3], outputs=3)
[6.0, 15.0, 21.0]
Out[3]:
[6.0, 15.0, 21.0]
insel.template('a_times_b', a=2, b=4)
streamlit¶
# save to web_app.py
# run with:
# streamlit run my_web_app.py
import streamlit as st
import insel
st.title("INSEL online")
x = st.slider("X", 0, 100, 25)
y = st.slider("Y", 0, 100, 25)
result = insel.block('SUM', x, y)
st.write(f"{x} + {y} = {result}")
random facts¶
In [22]:
Copied!
import requests
# Example: API for a random fact
url = "https://uselessfacts.jsph.pl/random.json?language=en"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
print("💡 Did you know?")
print(data['text'])
else:
print("Could not fetch the fact.")
import requests
# Example: API for a random fact
url = "https://uselessfacts.jsph.pl/random.json?language=en"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
print("💡 Did you know?")
print(data['text'])
else:
print("Could not fetch the fact.")
💡 Did you know? There are a million ants for every person on Earth.
rich¶
In [5]:
Copied!
from rich.progress import track
import time
for i in track(range(20), description="Hacking NASA..."):
time.sleep(0.1) # Simulate work
from rich.progress import track
import time
for i in track(range(20), description="Hacking NASA..."):
time.sleep(0.1) # Simulate work
Output()
pandas¶
In [6]:
Copied!
import pandas as pd
pd.read_csv('https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv')
import pandas as pd
pd.read_csv('https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv')
Out[6]:
| Survived | Pclass | Name | Sex | Age | Siblings/Spouses Aboard | Parents/Children Aboard | Fare | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 3 | Mr. Owen Harris Braund | male | 22.0 | 1 | 0 | 7.2500 |
| 1 | 1 | 1 | Mrs. John Bradley (Florence Briggs Thayer) Cum... | female | 38.0 | 1 | 0 | 71.2833 |
| 2 | 1 | 3 | Miss. Laina Heikkinen | female | 26.0 | 0 | 0 | 7.9250 |
| 3 | 1 | 1 | Mrs. Jacques Heath (Lily May Peel) Futrelle | female | 35.0 | 1 | 0 | 53.1000 |
| 4 | 0 | 3 | Mr. William Henry Allen | male | 35.0 | 0 | 0 | 8.0500 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 882 | 0 | 2 | Rev. Juozas Montvila | male | 27.0 | 0 | 0 | 13.0000 |
| 883 | 1 | 1 | Miss. Margaret Edith Graham | female | 19.0 | 0 | 0 | 30.0000 |
| 884 | 0 | 3 | Miss. Catherine Helen Johnston | female | 7.0 | 1 | 2 | 23.4500 |
| 885 | 1 | 1 | Mr. Karl Howell Behr | male | 26.0 | 0 | 0 | 30.0000 |
| 886 | 0 | 3 | Mr. Patrick Dooley | male | 32.0 | 0 | 0 | 7.7500 |
887 rows × 8 columns
In [7]:
Copied!
pd.read_csv('http://ultra.ericduminil.com/data/all_ultras.csv', sep=';')
pd.read_csv('http://ultra.ericduminil.com/data/all_ultras.csv', sep=';')
Out[7]:
| id | name | miles | division | laps | discipline | country | age | elapsed_time | kilometers | venue | year | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | miami_2025_151 | Joe Mazzone | 320.29200 | Open | 217 | Push | US | 30-39 | 23.92384 | 515.460 | Miami Ultra | 2025 |
| 1 | miami_2021_49 | Joe Mazzone | 313.90000 | Open | 215 | Push | US | 30-39 | 23.64750 | 505.173 | Miami Ultra | 2021 |
| 2 | dutch_2017_13 | Rick Pronk | 313.17108 | Open | 160 | Push | NL | 1-49 | 23.95963 | 504.000 | Dutch Ultra | 2017 |
| 3 | dutch_2018_18 | Rick Pronk | 311.21376 | Open | 159 | Push | NL | 1-49 | 23.91601 | 500.850 | Dutch Ultra | 2018 |
| 4 | miami_2016_201 | Andrew Andras | 309.52000 | Open | 212 | Push | US | 30-39 | 23.96444 | 498.124 | Miami Ultra | 2016 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 1569 | miami_2015_256 | Jennifer Gonzalez | 7.30000 | Women | 5 | Push | US | 19-29 | 8.89917 | 11.748 | Miami Ultra | 2015 |
| 1570 | miami_2019_26 | Zack Knezevic | 7.30000 | Open | 5 | Push | US | 30-39 | 17.43500 | 11.748 | Miami Ultra | 2019 |
| 1571 | miami_2025_138 | Scott Ziegler | 5.90400 | Open | 4 | Push | US | 40-49 | 23.14916 | 9.502 | Miami Ultra | 2025 |
| 1572 | miami_2022_132 | Zack K | 2.92000 | Open | 2 | Push | World | 40-49 | 13.85972 | 4.699 | Miami Ultra | 2022 |
| 1573 | miami_2023_64 | Leonard L Leffler | 1.46000 | Open | 1 | Paddle | US | 50-59 | 23.00992 | 2.350 | Miami Ultra | 2023 |
1574 rows × 12 columns
prettymapp¶
In [8]:
Copied!
from IPython.display import Image
Image(filename='images/roma.png')
from IPython.display import Image
Image(filename='images/roma.png')
Out[8]:
from prettymapp.geo import get_aoi
from prettymapp.osm import get_osm_geometries
from prettymapp.plotting import Plot
from prettymapp.settings import STYLES
aoi = get_aoi(address="Pantheon, Roma, Italy", radius=1100, rectangular=False)
df = get_osm_geometries(aoi=aoi)
fig = Plot(
df=df,
aoi_bounds=aoi.bounds,
draw_settings=STYLES["Peach"],
credits=False,
).plot_all()
fig.savefig("roma.png")
Satellite images?¶
In [9]:
Copied!
from IPython.display import Image
Image(filename='images/houat.png')
from IPython.display import Image
Image(filename='images/houat.png')
Out[9]: