Skip to content

Instantly share code, notes, and snippets.

View debboutr's full-sized avatar
💭
...working on it...

Rick Debbout debboutr

💭
...working on it...
View GitHub Profile
@debboutr
debboutr / stack.py
Last active October 24, 2020 06:11
pandas operations for stacking data -- jon launspach
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import pandas as pd
uid = "GEO_ID" # <-- set the column that will hold the unique ID
directory = "." # <-- set the directory that you want to read from here
@debboutr
debboutr / index.html
Last active November 20, 2018 20:57
Products linked to PUCs
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
top:30px;
margin:30px;
padding:30px;
}
.btn-group {
font-size:0;
gen_cat prod_fam prod_type description PUC_type num_prods
Arts and crafts/Office supplies 1 3
Arts and crafts/Office supplies body paint body paints, markers, glitters, play cosmetics, and halloween cosmetics 2 2
Arts and crafts/Office supplies children's art and toys 2 3
Arts and crafts/Office supplies children's art and toys bubble solution liquid bubble solutions, including solutions for bubble machines 3 1
Arts and crafts/Office supplies children's art and toys crayons wax crayons for coloring or illustration 3 0
Arts and crafts/Office supplies children's art and toys finger paint non-edible finger paints 3 2
Arts and crafts/Office supplies children's art and toys play dough children's play modeling clays 3 9
Arts and crafts/Office supplies fabric treatment and dye 2 7
Arts and crafts/Office supplies fabric treatment and dye fabric dye products for dying fabrics 3 0
@debboutr
debboutr / euclidean.py
Last active October 18, 2018 03:59
euclidean distance tool
import math
import numpy as np
def get_index_distance(index1, index2 ) :
home_x, home_y = index1
afar_x, afar_y = index2
squares = abs(home_x-afar_x)**2 + abs(home_y-afar_y)**2
return math.sqrt(squares)
def get_closest_index(array, index) :
@debboutr
debboutr / scrap.py
Last active October 18, 2018 07:20
scraper script built for home depot
import time
import random
import requests
import numpy as np
from ssl import SSLError
from bs4 import BeautifulSoup
from bs4.element import Tag
from requests import ConnectionError
url = 'https://www.homedepot.com/sitemap/d/plp_sitemap.xml'
# import dependencies
import urllib2,json,arcpy
import numpy as np
import pandas as pd
from django.utils.encoding import smart_str
import time
##################################################################################
# VARIABLES
# set working directory
@debboutr
debboutr / open_many_htmls.py
Created December 22, 2017 23:48
script to make a bat file that will open all html files in a directory
import os
here = 'path/to/htmls'
with open('%s/chrome.bat' % here,'w') as bat:
for f in os.listdir(here):
if f[-4:] == 'html':
bat.write('start chrome.exe %s/%s\n' % (here, f))
@debboutr
debboutr / mailServer
Created November 3, 2017 19:25
Start mail server python
(hem) C:\Users\Rdebbout>python -m smtpd -n -c DebuggingServer localhost:1025
@debboutr
debboutr / selRowsGPD.py
Created October 25, 2017 20:00
Load selected rows from shapefile into a geoDF
import fiona
import geopandas as gpd
from datetime import datetime as dt
def getRows(fn, lookupList, col=None):
reader = fiona.open(fn)
crs = reader.crs
if col == None:
return gpd.GeoDataFrame.from_features([reader[x] for x in lookupList],crs=crs)
else:
@debboutr
debboutr / zstats_30M.py
Last active October 25, 2017 00:25
Work-around for cell-size output from rasterstats package -- can't get through idx == 37
import numpy as np
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point
from rasterstats import point_query
from datetime import datetime as dt
nlcd = 'L:/Priv/CORFiles/Geospatial_Library/Data/Project/StreamCat/LandscapeRasters/QAComplete/nlcd2006.tif'
pre = 'D:/NHDPlusV21/NHDPlusGL/NHDPlus04'
cat = gpd.read_file('%s/NHDPlusCatchment/Catchment.shp' % pre)