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
s = 'Python is awesome!' | |
red = "#FA5882" | |
a = eval("exec('import sys; import matplotlib.pyplot as plt; import numpy as np; print(s); t = np.arange(0,2*np.pi, 0.1); x = 16*np.sin(t)**3; y = 13*np.cos(t)-5*np.cos(2*t)-2*np.cos(3*t)-np.cos(4*t); plt.fill(x,y,color=red); plt.show(); sys.exit()')") | |
print('R is great too!') | |
X11() # Use windows() or qartz() if on Windows or Mac | |
t = seq(0, 2*pi, by=0.1) | |
x = 16*sin(t)^3 | |
y = 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t) | |
plot(x=x, y=y, type="n", xlab="", ylab="") | |
polygon(x=x, y=y, col=red, border=red) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 __future__ import absolute_import | |
from __future__ import division | |
from __future__ import print_function | |
import sys | |
from absl import app | |
from absl import flags | |
from absl import logging |
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 __main__ | |
import pickle | |
from bz2 import BZ2File | |
from gzip import GzipFile | |
from typing import Optional, List | |
def save_env(path: str, objects: Optional[List[str]] = None, compress: str = 'gzip', protocol: int = -1): | |
""" | |
Save the environment (list of objects) of Jupyter Notebook into a compressed file |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# the code uses 'facebook' function from the previous gist (https://gist.github.com/1634662) or | |
# see the original http://romainfrancois.blog.free.fr/index.php?post/2012/01/15/Crawling-facebook-with-R | |
# scrape the list of friends | |
friends <- facebook( path="me/friends" , access_token=access_token) | |
# extract Facebook IDs | |
friends.id <- sapply(friends$data, function(x) x$id) | |
# extract names | |
friends.name <- sapply(friends$data, function(x) iconv(x$name,"UTF-8","ASCII//TRANSLIT")) | |
# short names to initials |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
library(tidyverse) | |
library(countrycode) # to counvert country names to 2 letter codes | |
library(ggflags) # for flags | |
library(gganimate) # for video | |
# Getting data ------------------------------------------------------------ | |
selected_countries <- c("Italy", "Spain", "France", "Germany", | |
"Portugal", "United States", "Slovakia", "South Korea", "Japan", | |
'Belgium', 'Sweden', |