A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
This post examines the features of [R Markdown](http://www.rstudio.org/docs/authoring/using_markdown) | |
using [knitr](http://yihui.name/knitr/) in Rstudio 0.96. | |
This combination of tools provides an exciting improvement in usability for | |
[reproducible analysis](http://stats.stackexchange.com/a/15006/183). | |
Specifically, this post | |
(1) discusses getting started with R Markdown and `knitr` in Rstudio 0.96; | |
(2) provides a basic example of producing console output and plots using R Markdown; | |
(3) highlights several code chunk options such as caching and controlling how input and output is displayed; | |
(4) demonstrates use of standard Markdown notation as well as the extended features of formulas and tables; and | |
(5) discusses the implications of R Markdown. |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
// Jeremie Miserez <jeremie@miserez.org>, 2015 | |
// | |
// A little bit of Javascript to let you export your Google Music library, playlists, and album track lists :) | |
// | |
// I posted this as an answer here: http://webapps.stackexchange.com/questions/50311/print-playlist-from-google-play-music | |
// | |
// 1. Go to: https://play.google.com/music/listen#/all (or your playlist) | |
// | |
// 2. Open a developer console (F12 for Chrome). Paste | |
// code below into the console. |
import geopandas as gpd | |
from shapely.geometry.polygon import Polygon | |
from shapely.geometry.multipolygon import MultiPolygon | |
def explode(indata): | |
indf = gpd.GeoDataFrame.from_file(indata) | |
outdf = gpd.GeoDataFrame(columns=indf.columns) | |
for idx, row in indf.iterrows(): | |
if type(row.geometry) == Polygon: | |
outdf = outdf.append(row,ignore_index=True) |
library(jsonlite);library(sf) | |
#lon = -123.1121 | |
#lat = 44.6390 | |
#state = 'OR' | |
watershed = function(state, lon, lat){ | |
p1 = 'https://streamstats.usgs.gov/streamstatsservices/watershed.geojson?rcode=' | |
p2 = '&xlocation=' | |
p3 = '&ylocation=' |
Earth Engine App
Earth Engine Code Editor script
/**
* @license
* Copyright 2021 The Google Earth Engine Community Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
library(sf) | |
library(mapview) | |
# read identifiers for Colorado River and Colorado River (TX) into simple features | |
colorado_river <- sf::read_sf("https://geoconnex.us/ref/mainstems/29559") | |
colorado_river_tx <- sf::read_sf("https://geoconnex.us/ref/mainstems/2639515") | |
## Function that constructs query to retrive the latest discharge observation from the USGS |
library(tidycensus) | |
library(tidyverse) | |
options(tigris_use_cache = TRUE) | |
state_names <- c(state.name, "District of Columbia") | |
names(state_names) <- state_names | |
tictoc::tic() | |
age_maps <- map(state_names, ~{ | |