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_ranges_in_between_ranges(df, start_name, stop_name): | |
""" | |
Get range boundaries in between range boundaries arranged to be strictly increasing. | |
For example if we had three range boundaries where the range start and stop values | |
are found in two separate columns in a dataframe, | |
start, stop | |
----------- | |
0, 5 | |
7, 8 |
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 create_logger(log_file_path, display_level, file_level): | |
""" | |
Logs to file as well as to display. | |
See https://www.dataquest.io/blog/advanced-jupyter-notebooks-tutorial/ | |
Args: | |
log_file_path (str): | |
display_level (int): logging.INFO for example | |
file_level (int): logging.INFO for example |
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
# See https://stackoverflow.com/questions/7894856/line-contains-null-byte-in-csv-reader-python | |
with open(path_to_csv_file) as f: | |
reader = csv.reader((x.replace('\0', '') for x in f), delimiter=',') # Handle null values | |
while True: | |
try: | |
line = next(reader) | |
except StopIteration: | |
break | |
print(line) # process lines |
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 os | |
import pendulum | |
def create_data_directory( | |
data_kind, # 'VolCal' | |
data_source_id, | |
timezone, | |
parent_directory | |
): |
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
set root=C:\Users\user\Anaconda3 | |
call %root%\Scripts\activate.bat %root% | |
call activate py37 | |
call cd "C:\Users\TNiederhauser\Dropbox (Medic)\MedicData\Floor Scale" | |
call jupyter lab |
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 verify_path_exists(path_): | |
try: | |
assert os.path.exists(path_) | |
except (AssertionError,) as error: | |
print() | |
print('Path not found') | |
print(path_) | |
raise FileNotFoundError |
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 | |
def levels_to_steps_post(x_vec, y_vec): | |
"""Provides data like matplotlib.pyplot.step with where set to 'post'""" | |
x_new = [None] * (len(x_vec) * 2 - 1) | |
y_new = [None] * (len(x_vec) * 2 - 1) | |
for i in range(len(x_vec)-1): | |
x_new[2*i] = x_vec[i] |
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
indices = np.unique(time_arr.values, return_index=True)[1] | |
time_strict = time_arr.values[indices] | |
response_strict = response_arr.values[indices] |
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
<head><script> | |
function initialize() | |
/* Initialize the web page */ | |
{ | |
/* Do stuff */ | |
} | |
</script></head> | |
<body onload="initialize()"> | |
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
<head> | |
<script> | |
window.setInterval(function() {myFunction()}, 500) | |
function myFunction() { | |
/* Do stuff */ | |
} | |
</script> | |
</head> |