This file contains hidden or 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 re | |
import copy | |
def apply_to_key(iterable, keys, func): | |
iterable = copy.deepcopy(iterable) | |
if isinstance(iterable, list): | |
for item in iterable: | |
iterable = clean(item, keys, func) | |
elif isinstance(iterable, dict): | |
for key, item in iterable.items(): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
# This is also applicable to other table which are styled similar. | |
import pandas as pd | |
with open("packagelist.txt") as file: | |
input_str = file.read() | |
column_widths = [len(dashes) for dashes in input_str.split("\n")[1].split()] | |
column_names = input_str.split("\n")[0].split() | |
data = {key: list() for key in column_names} | |
for line in input_str.split("\n")[2:]: |
This file contains hidden or 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
# index are integers | |
# when the index is already a time delete unit arg | |
pd.date_range( | |
start=pd.to_datetime(df.columns.min(), unit="h"), | |
end=pd.to_datetime(df.columns.max(), unit="h"), | |
freq="1H" | |
).time |
This file contains hidden or 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 = 20.3 | |
10**np.round(np.log10(a)) |