Skip to content

Instantly share code, notes, and snippets.

View casarock's full-sized avatar

Carsten Sandtner casarock

View GitHub Profile
import tweepy
import yaml
import coronaStats as st
def load_config():
with open("config.yaml", 'r') as stream:
try:
config = yaml.safe_load(stream)
return config
@casarock
casarock / plot_related.py
Created May 19, 2020 08:12
Plotting related data
@casarock
casarock / plot.py
Created May 19, 2020 08:11
plotting the diagram
def plot_diagram(self,
yvalue,
xlabel,
ylabel,
title,
filename):
plt.figure(figsize=(8,5))
ax = plt.gca()
self.overall.plot(kind='line',
@casarock
casarock / growth.py
Created May 19, 2020 08:10
Calculating growth
def get_weekly_growth(self):
frame = self.germany.tail(7)
actual = frame['sum'][-1]
days_before = frame['sum'][0]
growth_rate = (actual*100/days_before) - 100
return growth_rate
@casarock
casarock / calculate.py
Created May 19, 2020 08:09
Calculating interesting stuff
def get_actual_infected(self):
germany_changed = self.germany.tail(2)['sum'][1] - self.germany.tail(2)['sum'][0]
overall_changed = self.overall.tail(2)['sum'][1] - self.overall.tail(2)['sum'][0]
germany = '+' if germany_changed > 0 else '-'
overall = '+' if overall_changed > 0 else '-'
germany += str(germany_changed)
overall += str(overall_changed)
@casarock
casarock / cleaning.py
Created May 19, 2020 08:06
Cleaning part 2
def clean_Data(self, data_frame, country, drop_columns):
cleaned_data_frame = data_frame.drop(columns=drop_columns)
cleaned_data_frame = cleaned_data_frame.T
cleaned_data_frame['related'] = (100/self.population[country]) * cleaned_data_frame['sum']
return cleaned_data_frame
@casarock
casarock / cleaning.py
Last active May 19, 2020 07:18
Clean bot data
def get_clean_data(self):
df = pd.read_csv(self.csv_url)
df = df.drop(columns=['Lat', 'Long'])
df_group = df.groupby(['Country/Region'])
germany = df_group.get_group('Germany')
overall = df.agg(['sum'])
germany = germany.agg(['sum'])
@casarock
casarock / ClockView.swift
Created February 6, 2016 16:30
Custom Timer View in Swift
//: Playground - noun: a place where people can play
import UIKit
import XCPlayground
class ClockView: UIView {
private var shapeLayer = CAShapeLayer()
private var countDownTimer = NSTimer()
private var timerValue = 900
<link href="../core-animated-pages/core-animated-pages.html" rel="import">
<link href="../core-animated-pages/transitions/hero-transition.html" rel="import">
<link href="../core-animated-pages/transitions/cross-fade.html" rel="import">
<link href="../core-animated-pages/transitions/slide-down.html" rel="import">
<link href="../core-animated-pages/transitions/slide-up.html" rel="import">
<link href="../core-animated-pages/transitions/tile-cascade.html" rel="import">
<link href="../core-field/core-field.html" rel="import">
<link href="../core-icon/core-icon.html" rel="import">
<link href="../core-input/core-input.html" rel="import">
<link href="../core-icons/core-icons.html" rel="import">
Acc.Game = function (game) {
this.game = game;
};
Acc.Game.prototype = {
create: function () {
this.MAX_VELX = 125;