Skip to content

Instantly share code, notes, and snippets.

View mlisovyi's full-sized avatar
🏠
Working from home

Mischa Lisovyi mlisovyi

🏠
Working from home
View GitHub Profile
@mlisovyi
mlisovyi / fit_with_integral.py
Created December 31, 2023 16:38
Fit a curve to a binned distribution
# %%
from typing import Iterable
import numpy as np
from matplotlib import pyplot as plt
from scipy import integrate
from scipy.optimize import curve_fit
from scipy.stats import beta
if __name__ == "__main__":
@mlisovyi
mlisovyi / compare_excel_vs_contents_of_folders.py
Created May 14, 2020 20:26
Compare an excel with many tabs vs files in a set of folders
from pathlib import Path
import shutil
import pandas as pd
# inputs
dirs = [Path.cwd().joinpath("dir2"), Path.cwd().joinpath("dir1")]
for _dir in dirs:
if not _dir.is_dir():
raise IOError(f"Can not find {_dir}.")
@mlisovyi
mlisovyi / compare_folders.py
Last active May 14, 2020 06:37
Compare contents of 2 folders by filename and copy unique files from the first one
from pathlib import Path
import shutil
# inputs
input_dir = Path.cwd().joinpath("INPUTS")
result_dir = Path.cwd().joinpath("RESULTS")
if not input_dir.is_dir():
raise IOError(f"Make sure there is {input_dir} folder in the current folder")
if not result_dir.is_dir():
raise IOError(f"Make sure there is {result_dir} folder in the current folder")
@mlisovyi
mlisovyi / countryinfo.py
Last active October 27, 2024 18:57 — forked from pamelafox/countryinfo.py
Python list of country codes, names, continents, capitals, and pytz timezones (original + Hong Kong + Taiwan + Kosovo + Puerto Rico + fix Haiti ISO)
countries = [
{'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'},
{'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'},
{'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"},
{'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'},
{'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'},
{'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'},
{'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai