Skip to content

Instantly share code, notes, and snippets.

@ZeccaLehn
ZeccaLehn / csv_jupyter.py
Last active January 18, 2020 03:48
CSV Download and Upload Collab Jupyter Python
## Download
from google.colab import files
df.to_csv('df.csv')
files.download('df.csv')
## Upload
from google.colab import files
df = files.upload()
## Save CSV on remotely in Colab
@ZeccaLehn
ZeccaLehn / socialExtract.py
Last active October 6, 2019 04:02
Get all social links / emails from HTML site
from urllib.request import urlopen
from bs4 import BeautifulSoup
import pandas as pd
import random
from urllib.parse import urlparse
import urllib.request
import lxml.html
# randLink = str(seedFunds.iloc[int(random.uniform(1, len(seedFunds))), 4])
@ZeccaLehn
ZeccaLehn / boxplotPython.py
Created July 17, 2019 21:38
Boxplot Python
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
data = pd.read_csv('Stages.csv').dropna()
x = "Stage"
y = "Experimental"
plt.figure(figsize=(15,16))
@ZeccaLehn
ZeccaLehn / MergeOverlappingTables.R
Created June 26, 2015 03:26
[R] Merge Overlapping Tables using Multiple Keys (Data.Table)
library(data.table)
DM = data.table(X = 1:5 , B = c("a", letters[6:7], NA, NA), D = c("g",
letters[22:25]), Y = c("j", letters[6:9]) )
keycols = names(DM)
setkeyv(DM, keycols)
DT = data.table(X = 1:5, B = c("a", letters[6:9]),
D = c("g", letters[2:5]), Y = c("j", letters[16:19]))
@ZeccaLehn
ZeccaLehn / condaRandPython.txt
Last active May 22, 2019 08:50
GCP/GCloud VM setup running R/Python using Anaconda
####### GCP/GCloud VM setup running R/Python using Anaconda ########
# Prepared as part of a guest lecture series in parallel programming and GCloud setup
# at Pepperdine University for their inaugural ML class on 3/16/2018.
# Rights: MIT Licence
## 10 easy steps: Running R/Python in the cloud
1) Log into GCP
2) Create a project (if not done already), and log into <your project> from top of screen
@ZeccaLehn
ZeccaLehn / pageHrefs.txt
Last active April 26, 2019 15:54
CSV Download from document withing Javascript JS
var allDeals = document.getElementsByClassName('u-uncoloredLink js-syndicate_click');
var links = []
for (var i=0; i < allDeals.length; i++) {
links.push(allDeals[i].getAttribute('data-url'));
};
var csvContent = "data:text/csv;charset=utf-8,";
links.forEach(function(rowArray){
csvContent += rowArray + "\r\n";
@ZeccaLehn
ZeccaLehn / csvFromJupyter.py
Last active March 7, 2019 00:11
Download CSVs Directly from JupyterNotebook or Google DataLab
import pandas as pd
from IPython.display import FileLinks # FileLink
import os
data = pd.DataFrame([['a', 'b'],['c', 'd'],['e','f']], columns = ['foo', 'bar']) # .values.tolist()
directory = 'testdata/'
filename = 'data2.csv'
pathtofile = directory + filename
if not os.path.exists(directory):
@ZeccaLehn
ZeccaLehn / GPUjupyter.txt
Created January 22, 2019 17:59
Gcloud: Jupyter Notebook with GPUs from browser
###### Gcloud: Jupyter Notebook with GPUs from browser
## First Step Install GCP 16.04 LTS with 20GB and Tesla K80 NVIDIA GPU and HTTP/HTTPS
## From Remote shell (*need to run twice after generating keys). Can also use SSH with default user
gcloud compute --project <project name> ssh --zone "us-central1-a" <gce name>
## Install Anaconda and setup path
# Required upfront: Installs nano / curl / bzip2 / etc.
sudo -s
@ZeccaLehn
ZeccaLehn / directEconometric.py
Created January 18, 2019 21:12
Econometric Python Direct Install
# Adapted for python 3
# https://github.com/pbharrin/pyconometrics
'''
Created on Aug 17, 2010
@author: Peter Harrington
peter.b.harrington@gmail.com
'''
from numpy import *
@ZeccaLehn
ZeccaLehn / neo4j-GrapheneDB.ipynb
Last active December 19, 2018 01:32
Booting-Up Your Network with GrapheneDB using Neo4j and Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.