Skip to content

Instantly share code, notes, and snippets.

View oztalha's full-sized avatar

Talha Oz oztalha

View GitHub Profile
@wrobstory
wrobstory / README.md
Last active March 22, 2022 21:06
Folium Employed Choropleth

A Leaflet.js map created with Folium and the default D3 threshold scale, with data bound between the Pandas DataFrame and the TopoJSON. See the Gist for the python code to generate the dataframe. The map was generated with the following Python code:

map_1 = folium.Map(location=[48, -102], zoom_start=3)
map_1.geo_json(geo_path=county_geo, data_out='data1.json', data=df,
               columns=['GEO_ID', 'Employed_2011'],
               key_on='feature.id',
               fill_color='YlOrRd', fill_opacity=0.7, line_opacity=0.3,
               topojson='objects.us_counties_20m')
map_1.create_map(path='map_1.html')
@thiagomarzagao
thiagomarzagao / wordscores.py
Last active December 18, 2015 07:19
The Python script below implements the ‘wordscores’ algorithm (see Laver, M., Benoit, K., Garry, J. Extracting policy positions from political texts using words as data. American Political Science Review, 97(2), 2003, pp. 311-331). It takes as inputs word-frequency matrices. These matrices must be in CSV format. The first column must contain the…
### WORDSCORES (LBG-2003)
### author: Thiago Marzagao
### contact: marzagao ddott 1 at osu ddott edu
import os
import numpy as np
import pandas as pd
ipath = '/Users/username/inputdata/' # folder containing the CSV files
opath = '/Users/username/outputdata/' # folder where output will be saved
@rjweiss
rjweiss / Python_classification
Last active August 25, 2016 23:06
Python notebook from MozFest 2013
{
"metadata": {
"name": "Python_classification.ipynb"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
import os, sys
import subprocess, signal
import time
from bs4 import BeautifulSoup
import selenium as sl
from selenium.webdriver import Firefox, FirefoxProfile
URL = 'https://www.usefulservice.com/'
@oztalha
oztalha / Population Synthesis for ABM.ipynb
Last active November 20, 2023 09:56
Generation of Realistic Mega-City Populations and Social Networks for Agent-Based Modeling
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@laurencee9
laurencee9 / draw_curved_edges.py
Last active July 9, 2019 19:34
Draw curved network edges in python
import numpy as np
import matplotlib.patches as mpatches
import networkx as nx
from matplotlib.patches import FancyArrowPatch as ArrowPath
from matplotlib.font_manager import FontProperties
def draw_curved_edges(edges, pos, ax, mu=0.05, edge_color="black", edge_width=1.0, alpha=1.0, arrow_scale=20.0, loopsize=0):
"""