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 contextily as cx | |
# read data | |
df = gpd.read_file('data/arrondissements/arrondissements.shp',encoding='utf-8') | |
df = df.to_crs(epsg=3857) | |
fig, ax = plt.subplots(1, figsize=(10, 6),dpi=300,facecolor='w',edgecolor='w') | |
# colorbar | |
divider = make_axes_locatable(ax) | |
cax = divider.append_axes('right', size='5%', pad=0.3) |
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
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv", dtype={"fips": str}) | |
df.rename(columns={'fips':'GEOID'}, inplace=True) | |
# read US county shapefile | |
county_map = gpd.read_file('data/cb_2018_us_county_500k/cb_2018_us_county_500k.shp') | |
county_map = county_map[~county_map.STATEFP.isin(['02','15','72','60','66','69','78','11'])] | |
county_map = county_map.to_crs("EPSG:2163") | |
# read US state shapefile | |
state_map = gpd.read_file('data/cb_2018_us_state_500k/cb_2018_us_state_500k.shp') |
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 pandas as pd | |
import geopandas as gpd | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.axes_grid1 import make_axes_locatable | |
# read data | |
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv') | |
df.rename(columns={'code':'STUSPS'}, inplace=True) | |
# read US state shapefile |
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 pandas as pd | |
import geopandas as gpd | |
import plotly.express as px | |
# read data | |
df = pd.read_csv('data/population.csv',header=2) | |
df.rename(columns={'Country Code':'iso3'}, inplace=True) | |
# read shapefile | |
map = gpd.read_file('data/world-administrative-boundaries/world-administrative-boundaries.shp') | |
# merge df and shapefile |
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 argparse import ArgumentDefaultsHelpFormatter, ArgumentParser | |
from sklearn.datasets import make_classification | |
from sklearn.decomposition import PCA | |
from sklearn.manifold import LocallyLinearEmbedding | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.svm import SVC | |
from sklearn.ensemble import RandomForestClassifier | |
from sklearn.model_selection import train_test_split | |
from sklearn.metrics import accuracy_score | |
from gooey import Gooey |
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
for dim_red_type in 'pca' 'lle'; do | |
for n_comp in 5 10; do | |
for classifier in 'lr' 'svc' 'rf'; do | |
echo $dim_red_type $n_comp $classifier | |
python argparse_automate.py --dim_red_type "${dim_red_type}" --n_comp "${n_comp}" --classifier "${classifier}" | |
done | |
done | |
done |
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 argparse import ArgumentDefaultsHelpFormatter, ArgumentParser | |
def parse_args(): | |
parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter, | |
conflict_handler='resolve') | |
parser.add_argument('--dim_red_type', default='pca', choices=[ | |
'pca','lle'], help='The dim red. types') | |
parser.add_argument('--n_comp', default=10,type=int, choices=[ | |
5,10], help='output dimensions') | |
parser.add_argument('--classifier', default='lr', choices=[ |
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 sklearn.datasets import make_classification | |
from sklearn.decomposition import PCA | |
from sklearn.manifold import LocallyLinearEmbedding | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.svm import SVC | |
from sklearn.ensemble import RandomForestClassifier | |
from sklearn.model_selection import train_test_split | |
from sklearn.metrics import accuracy_score | |
# arguments |
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 | |
st.set_page_config(layout="wide") | |
#------------------- | |
# Streamlit Sidebar | |
#------------------- | |
fiat = ['USD','EUR','GBP'] | |
tokens = df_scrape.Symbol.values |
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
df_scrape["color"] = df_scrape["% Change"].map(lambda x:'red' if x<0 else 'green') | |
cols_to_show = ['Name','Token', 'Price', '% Change', 'Market Cap'] | |
# to change color of "% change" column | |
fill_color = [] | |
n = len(df_scrape) | |
for col in cols_to_show: | |
if col!='% Change': | |
fill_color.append(['black']*n) | |
else: |
NewerOlder