Skip to content

Instantly share code, notes, and snippets.

View jhconning's full-sized avatar

Jonathan Conning jhconning

View GitHub Profile
# Example
shpfile = r'zip://ag1860/1860county.zip'
gdf = GeoDataFrame.from_file(shpfile)
@jhconning
jhconning / Fenske.ipynb
Created November 18, 2017 17:10
Murdock atlas and Fenske paper
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jhconning
jhconning / gist:5afa690e8a844226f5574e93e310303f
Created September 11, 2017 05:36
jupyter to PDF conversion without heading numbering
From: https://stackoverflow.com/questions/20264909/suppress-section-numberings-in-nbconvert-to-latex
create: secnum.tplx
---------------------------------
((* extends 'article.tplx' *))
((* block commands *))
\setcounter{secnumdepth}{0} % Turns off numbering for sections
((( super() )))
((* endblock commands *))
@jhconning
jhconning / rpycdemo.ipynb
Last active December 24, 2023 03:01
Run Jupyter notebook to control ev3 using ev3dev via rpyc server
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jhconning
jhconning / gist:9e0b6cf4900a46e4400d3ee6c3b517b9
Created July 4, 2017 01:29
read SQL into pandas with pymysql
import pandas as pd
import pymysql
mysql_connection = pymysql.connect(host='localhost',
user='root',
password='',
db='tutorfall2016',
charset='utf8',
cursorclass=pymysql.cursors.DictCursor)
@jhconning
jhconning / gist:5d1b1310d4cfb61639aec78618dda7d5
Created May 26, 2017 06:12
Sympy latex printing in jupyter
from sympy import init_printing; init_printing(use_latex='mathjax')
@jhconning
jhconning / gist:22faf25a9203c3c592caf7eb07f866fc
Created May 6, 2017 03:00
pandas multiindex and groupby
# to create a multinindex
df.sort_values(by = ['Year', 'UnitDesc','bin'], inplace = True)
df = df.set_index(['Year', 'UnitDesc','bin'],drop = False)
# To turn one level of the index into a column
df = df.unstack('UnitDesc')['Value']
df.head()
# to pull out all data in level='Year'
@jhconning
jhconning / aganalytics_python.api.ipynb
Created May 5, 2017 19:33
sample python code for ag-analytics.org API
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jhconning
jhconning / gist:6e6fafa15af5c1f87237e7c50a20f4c3
Created May 2, 2017 02:01
pandas: list comprehension to drop columns that match condition
def drop_cols(df):
'''drop columns that don't vary'''
df.drop([ col for col in df.columns if (len(df[col].unique()) == 1)],
axis=1, inplace=True)
@jhconning
jhconning / Folium_markers
Created March 7, 2017 18:52
Folium map markers and zipfile
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Mapping largest cities\n",
"## Experiments with folium, zipfile and pandas"
]
},