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.loc[len(df.index)] = list(df.columns) |
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
#create two new columns via attribute table | |
#via: https://gis.stackexchange.com/questions/45243/how-to-determine-the-centroid-of-polygons | |
long = toreal(regexp_substr(geom_to_wkt(centroid($geometry)), '(-?\\d+\\.?\\d*) -?\\d+\\.?\\d*')) | |
lat = toreal(regexp_substr(geom_to_wkt(centroid($geometry)), '-?\\d+\\.?\\d* (-?\\d+\\.?\\d*)')) |
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
data_dir10 = '../data/2010/tx2010.pl/' | |
FILES10 = { | |
'cols': '../data/2010/2010_PLSummaryFile_FieldNames.xlsx', | |
'geoheader': data_dir10+'txgeo2010.pl', | |
'seq01': data_dir10+'tx000012010.pl', | |
'seq02': data_dir10+'tx000022010.pl', | |
} | |
def return_dtypes_dict(df): |
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
right( ('000' || tostring( "myfield" )), 4) |
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: https://github.com/cogeotiff/cog-spec/blob/master/spec.md | |
# You need to install GDAL first | |
# Run this on the command line, replace in.tif and out.tif with your desired file names | |
gdal_translate in.tif out.tif -co TILED=YES -co COPY_SRC_OVERVIEWS=YES -co COMPRESS=LZW |
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 numpy as np | |
import glob | |
import matplotlib.pyplot as plt | |
import re | |
def linechart(df, x_dim, y_dim, xaxis, yaxis, title): | |
fig, ax = plt.subplots(figsize=(15, 7)) | |
if x_dim == 'index': |
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
virtualenv -p python3 envname |
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
basepath = '../data/restaurant-violations/csv/' | |
df_list = [] | |
for filename in os.listdir(basepath): | |
filepath = os.path.join(basepath, filename) | |
print(filepath) | |
if filename.endswith('.csv'): | |
df = pd.read_csv(filepath) | |
df_list.append(df) | |
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
#R | |
filepath <- 'path/to/folder' | |
file.rename(dir(filepath, full.names = TRUE), tolower(dir(filepath, full.names = TRUE))) | |
# If your working directory is set to the folder you don't need `full.names = TRUE` | |
# But it's best to not change your working directory |
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
# works with python3 and python2 | |
from slugify import slugify | |
import os | |
directory = 'all-lower/' | |
for old_filename in os.listdir(directory): | |
old_filename_pieces = os.path.splitext(old_filename) |
NewerOlder