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 numpy as np | |
import matplotlib.image as img | |
import matplotlib.pyplot as plt | |
image = img.imread('school.png') # Grab the image | |
def toGreyscale(image): | |
# convert the RGB to Greyscale | |
return np.dot(image[...,:3], [0.114, 0.299, 0.587]) |
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 math as m | |
import kMath as km | |
import matplotlib.pyplot as plt | |
A = .96 #initial height | |
ma = 5.0 #mass | |
k = 2.1 #spring constant | |
b = 0.09 #dampening | |
theta = 0 #phase angle | |
w = m.sqrt(k / ma) |
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
# make a movie from images | |
import glob | |
import imageio | |
import os | |
path_name = "img/*.png" | |
# grab files, sorted by modification time | |
#filenames = glob.glob("img/*.png") |
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 matplotlib.pyplot as plt | |
from matplotlib import dates | |
import datetime | |
from pandas.plotting import register_matplotlib_converters | |
register_matplotlib_converters() | |
# TODO: Turn this bad boy into a function | |
# Raw data example (Format will vary) |
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
# Wald-Wolfowitz Runs Test (Actual) | |
# *** For educational purposes only, | |
# use more robust code for actual analysis | |
import math | |
import scipy.stats as st # for pvalue | |
# Example data (Current script only works for binary ints) | |
L = [1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,0,1,0,0,1,0,0,1,1,1,0,0,0,1] |
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
# To clean and convert a whatsapp txt file export to a CSV file | |
import pandas as pd | |
# read file by lines | |
file_path = "whatsapp.txt" | |
f = open(file_path, 'r') | |
data = f.readlines() | |
f.close() |
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
# Modified 190812 k | |
# Be sure to add to the list of packages in deployment.py | |
# /usr/lib/python3/dist-packages/landscape/sysinfo/deployment.py | |
from twisted.internet.defer import succeed | |
from requests import get | |
current_instance = None | |
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
def strpMailTime(timestamp): | |
if len(timestamp) < 27: | |
# Ex. '5 Nov 2018 12:05:07 -0500' len 25 | |
# '28 Oct 2019 03:33:57 -0400' len 26 | |
dt = datetime.datetime.strptime(timestamp, "%d %b %Y %H:%M:%S %z") | |
elif len(timestamp) > 29 and len(timestamp) < 32: | |
# 'Fri, 6 Dec 2019 15:22:49 +0000' len 30 | |
# 'Mon, 09 Dec 2019 14:19:26 +0000' len 31 | |
dt = datetime.datetime.strptime(timestamp, "%a, %d %b %Y %H:%M:%S %z") | |
elif len(timestamp) > 35 and len(timestamp) < 39: |
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 | |
import matplotlib.pyplot as plt | |
import matplotlib.dates as mdates | |
import datetime | |
import random | |
import matplotlib.ticker as mticker | |
from pandas.plotting import register_matplotlib_converters | |
register_matplotlib_converters() |
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
def scaleInRange(lon, a, b): | |
r_max, r_min = max(lon), min(lon) | |
slon = [] | |
for i in lon: | |
slon.append(((i - r_min) / (r_max - r_min)) * (b - a) + a) | |
return slon | |
# Example | |
lon = range(1,100) | |
a, b, = 4, 8 |
OlderNewer