import requests
from IPython.display import Image
url = "https://github.com/Octoframes/jupyter_capture_output/blob/main/assets/cute_dog.jpg?raw=true"
response = requests.get(url)
Image(response.content , embed=True, width=400)

import requests
from pathlib import Path
url = 'https://github.com/Octoframes/jupyter_capture_output/blob/main/assets/dog_with_water.mp4?raw=true'
p = Path.home() /'Downloads/dog_with_water.mp4'
p.write_bytes(requests.get(url).content);
p = Path.home() /'Downloads/dog_with_water.mp4'
from IPython.display import Video
Video(p, embed=True, width=600)
Loading...
import requests
from IPython.display import Image
url = "https://media.giphy.com/media/KAq5w47R9rmTuvWOWa/giphy.gif"
response = requests.get(url)
Image(response.content , embed=True, width=100)

from IPython.display import SVG
url = "https://openmoji.org/data/color/svg/1F9F9.svg"
response = requests.get(url)
SVG(response.content)
Loading...
import numpy as np
import pandas as pd
weather_df = pd.DataFrame(np.random.rand(10,2)*5,
index=pd.date_range(start="2021-01-01", periods=10),
columns=["Tokyo", "Beijing"])
def rain_condition(v):
if v < 1.75:
return "Dry"
elif v < 2.75:
return "Rain"
return "Heavy Rain"
def make_pretty(styler):
styler.set_caption("Weather Conditions")
styler.format(rain_condition)
styler.format_index(lambda v: v.strftime("%A"))
styler.background_gradient(axis=None, vmin=1, vmax=5, cmap="YlGnBu")
return styler
weather_df
Loading...
# twitter class
import requests
class Tweet(object):
def __init__(self, s, embed_str=False):
if not embed_str:
# Use Twitter's oEmbed API
# https://dev.twitter.com/web/embedded-tweets
api = 'https://publish.twitter.com/oembed?url={}'.format(s)
response = requests.get(api)
self.text = response.json()["html"]
else:
self.text = s
def _repr_html_(self):
return self.text
Tweet("https://twitter.com/MystMarkdown/status/1663126818302435332")
Loading...
# #| label: my-compare_view
# from PIL import Image
# import requests
# import matplotlib.pyplot as plt
# import numpy as np
# from jupyter_compare_view import compare
# image = Image.open(requests.get("https://raw.githubusercontent.com/scikit-image/scikit-image/main/skimage/data/chelsea.png", stream=True).raw)
# image = np.uint8(image)
# image_grey = image[:,:,0]
# compare(image, image_grey, add_controls=False, start_mode="horizontal", start_slider_pos= 0.23, cmap="gray")