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) |
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
################################################################ | |
# | |
# Recognize text in all image files in a certain directory | |
# And write it to seperate or one textfile(s) or a SQLite3 database | |
# | |
################################################################# | |
# Make sure you installed Pytesseract : https://stackoverflow.com/questions/50951955/pytesseract-tesseractnotfound-error-tesseract-is-not-installed-or-its-not-i | |
# TODO : clear confusion betweend dir_name and rootdir |
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 collections import Counter | |
puzzle_words = ["gebit", | |
"sober", | |
"lonen", | |
"jarig", | |
"deken", | |
"nodig", | |
"spoor", |
NewerOlder