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 reverse_geocoder as rg | |
import csv | |
with open("output.csv", 'w') as outf: | |
writer = csv.writer(outf) | |
writer.writerow(['index', 'lat', 'lon', 'datetime', 'country', 'location', 'area1', 'area2'']) | |
with open("input.csv", 'r') as inf: | |
reader = csv.reader(inf) | |
reader.next() |
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 | |
df_gps = pd.read_json('input.json') | |
# parse lat, lon, and timestamp from the dict inside the locations column | |
df_gps['lat'] = df_gps['locations'].map(lambda x: x['latitudeE7']) | |
df_gps['lon'] = df_gps['locations'].map(lambda x: x['longitudeE7']) | |
df_gps['timestamp_ms'] = df_gps['locations'].map(lambda x: x['timestampMs']) | |
# convert lat/lon to decimalized degrees and the timestamp to date-time |
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
# -*- coding: utf-8 -*- | |
import tableauserverclient as TSC | |
# migrate from | |
site = "" | |
user = "" | |
pwd = "" | |
tableau_auth = TSC.TableauAuth(user, pwd, site_id=site) | |
server = TSC.Server('https://dub01.online.tableau.com') |
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 pybikes | |
import csv | |
bike_system = "bicing" | |
bicing = pybikes.get(bike_system) | |
print bicing.meta | |
bicing.update() |
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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"##Importing the **Extract API**" | |
] | |
}, | |
{ |
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 textblob import Word | |
import re | |
def parse(text): | |
pattern = '''Synset\(\'(.*)\.n''' | |
return re.findall(pattern,text)[0] | |
def classify(word): | |
try: | |
word = Word(word) |
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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"We are working with Comma-separated value (CSV) files, so we'll need that library." | |
] | |
}, | |
{ |
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
{"nbformat_minor": 0, "cells": [{"execution_count": null, "cell_type": "code", "source": "print \"Hello, world!\" #ohai! this is a comment", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "name = \"Eric\" # creating a variable\nprint \"Hello\" + \" \" + name # adding strings", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "your_name = raw_input(\"Who are you? \")\nprint \"Hello\", your_name # , adds spaces", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "print your_name.lower() # string method\nprint your_name.upper()", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "i = 0\nprint i\ni = i + 1 # i += 1\nprint i", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, " |
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 TwitterSearch import * | |
import csv | |
def get_tweets(query, max = 2000): | |
# takes a search term (query) and a max number of tweets to find | |
# gets content from twitter and writes it to a csv bearing the name of your query | |
i = 0 | |
search = query |
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 random import randrange, random, choice | |
import dataextract as tde | |
import os | |
import string | |
import time | |
import csv | |
def write_to_extract(rows_to_write, name): | |
start = time.time() |