Skip to content

Instantly share code, notes, and snippets.

View amdevine's full-sized avatar

Amanda Devine amdevine

  • Washington, D.C.
View GitHub Profile
@amdevine
amdevine / rename-files.py
Created October 4, 2023 19:12
Bulk rename files in Python
# Adapted from Automate the Boring Stuff with Python
# https://automatetheboringstuff.com/2e/chapter10/
import shutil, os
from pathlib import Path
dir = Path.cwd() / 'data_directory'
for f in os.listdir(dir):
@amdevine
amdevine / excel-lambda-let.md
Last active August 9, 2022 14:04
Excel: Custom functions with LAMBDA and LET
@amdevine
amdevine / count-unique-excel.md
Last active October 19, 2021 18:20
Count unique, non-blank taxa in Excel

1. Make table

Make tabular data into a table (Insert → Table). Assign a short name to the table (Table Design → Table Name).

Table: taxa

A B C D E F
1 kingdom phylum class order family genus
2 Animalia Mollusca Gastropoda Neogastropoda Fasciolariidae Fasciolaria
@amdevine
amdevine / encode-dummy-variables.ipynb
Created September 23, 2021 04:32
Encode dummy variables with dplyr
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@amdevine
amdevine / tracheophyta.md
Created June 2, 2021 16:58
Tracheophyte Taxa

Taxa of Tracheophytes

This gist contains plant taxa considered tracheophytes for resources that do not recognize "Tracheophyta" as a division.

BOLD

Division Tracheophyte?
Bryophyta No
Chlorophyta No
@amdevine
amdevine / df-rename-columns-index.ipynb
Created March 31, 2021 02:17
Modify Pandas DataFrame column and index labels with functions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@amdevine
amdevine / consolidate-rows.R
Last active March 9, 2021 05:04
Consolidate multiple household records into one household record
# Use dplyr package
library(dplyr)
# Create example data frame
data <- data.frame(personal_id = c(1, 2, 3, 4, 5, 6),
name = c('Albert', 'Beth', 'Cindy', 'David', 'Eugene', 'Fred'),
household_id = c('1H', '1H', '2H', '2H', '3H', '3H'),
score1 = c(3, NA, 1, NA, 1, NA),
score2 = c(5, NA, NA, 2, 2, NA),
score3 = c(NA, 'banana', 'cherry', NA, 'eggplant', NA),
@amdevine
amdevine / surveys2001.csv
Created March 2, 2021 07:30
Surveys 2001 and 2002
record_id month day year plot_id species_id sex hindfoot_length weight
31711 1 21 2001 1 PB F 26.0 25.0
31712 1 21 2001 1 DM M 37.0 43.0
31713 1 21 2001 1 PB M 29.0 44.0
31714 1 21 2001 1 DO M 34.0 53.0
31715 1 21 2001 2 OT M 20.0 27.0
31716 1 21 2001 2 RM M 17.0 11.0
31717 1 21 2001 2 NL M 33.0 121.0
31718 1 21 2001 2 DM F 34.0 44.0
31719 1 21 2001 2 PB M 26.0 42.0
@amdevine
amdevine / readme.md
Last active February 22, 2021 16:23 — forked from maartenzam/readme.md
World Tile Grid Map in ggplot2