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 get_data_eurostat(): | |
"""Get from Eurostat : Deaths by week, sex and 5-year age group | |
Data from https://ec.europa.eu/eurostat/databrowser/product/view/demo_r_mwk_05?lang=en | |
https://ec.europa.eu/eurostat/databrowser/bookmark/fbd80cd8-7b96-4ad9-98be-1358dd80f191?lang=en | |
https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/dataflow/ESTAT/DEMO_R_MWK_05/1.0?references=descendants&detail=referencepartial&format=sdmx_2.1_generic&compressed=true | |
Returns: | |
df: dataframe with weekly mortality in 5 year tranches | |
DATAFLOW LAST UPDATE freq age sex ... OBS_VALUE OBS_FLAG age_sex jaar weeknr |
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 streamlit as st | |
import plotly.graph_objects as go | |
import numpy as np | |
import statsmodels.api as sm | |
// output: https://twitter.com/rcsmit/status/1800539585841344854 | |
def test(): | |
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
# recreating https://twitter.com/NateB_Panic/status/1636811443612860417/photo/1 | |
import numpy as np | |
import plotly | |
import plotly.graph_objects as go | |
import numpy as np | |
p_values = [0.01, 0.05,0.1,0.2, 0.3, 0.5] # set the values of p | |
x = np.arange(0, 30, 1) # generate an array of x values from 0 to 10 |
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
""" A script to calculate the loss or gain after x months working in a year with a montly salary of y | |
This calculation is a simplification | |
Goal is to learn to work with OOP and make the script pythonic as much as possible. | |
TODO : calculate the total capital after z years, with taking inflation in account | |
Returns: | |
A dataframe like this: |
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
# For each accotype: The first number is the name of the acco, second number is the first row and third number is the last row | |
to_do_2022 = [ | |
[1, 4, 9], # ALPHA | |
[11, 14, 23], # BRAVO | |
] | |
def make_complete_df(columns_to_use, year): | |
"""Generate the dataframe | |
Columns: ['acco_type', 'number', 'date',"month","year", "new_arrival","departure_no_clean", "departure_clean", "back_to_back", "yellow"]) |
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 find_fill_color(cell): | |
"""Find fill color of a cell. | |
Hulproutine, wordt niet aangeroepen in het script | |
# dirty solution to find the fill color. | |
# as solutions given here https://stackoverflow.com/questions/58429823/getting-excel-cell-background-themed-color-as-hex-with-openpyxl | |
# dont work | |
Args: | |
cell (string): The cell you want to find the color from |
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 | |
from openpyxl import load_workbook | |
import urllib.request | |
local = False | |
if local: | |
excel_file = r"C:\Users\rcxsm\Documents\python_scripts\streamlit_scripts\input\dummy_occupation.xlsx" | |
wb = load_workbook(excel_file, data_only=True) | |
else: | |
excel_file = r"https://github.com/rcsmit/streamlit_scripts/blob/main/input/dummy_occupation.xlsx?raw=true" |
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
# adaption of the solutioon given by Derek O to make it easy to reuse | |
# https://stackoverflow.com/questions/70129355/value-annotations-around-plotly-sunburst-diagram | |
import pandas as pd | |
import plotly.express as px | |
import plotly.graph_objects as go | |
from math import sin,cos,pi | |
import plotly.io as pio |
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
for (m in 1:10){ | |
x = m/10 #new in R so I dont know how to make steps of .1 in loops ;) | |
monsterlist <- c() #This will hold the number of disabled in each sim run | |
for (h in 1:1){ #Repeat simulation 1 times | |
disabled <- c() #This will hold the disabled within each sim run | |
population <- as.vector(c(rep(0,10000))) #The population of 10,000 | |
for(j in 1:30) { # Number of Years | |
infected <- sample(1:length(population),floor(x*length(population))) # infect x% of the population every year | |
population[infected] <- population[infected]-1 #infected get an increasingly-negative counter | |
# The next 2 paragraphs control who gets LC. One should be commented out. |
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 sqlite3 as sl | |
import pandas as pd | |
import streamlit as st | |
import os | |
from PIL import Image | |
def delete_records_from_db(dir): | |
sql_statement = f"DELETE FROM txt_from_images WHERE directory = '{dir}'" | |
db_name = dir + os.sep + "my_test.db" | |
con = sl.connect(db_name) |
NewerOlder