from threading import Thread
class ThreadWithResult(Thread):
def __init__(self, group=None, target=None, name=None, args=(), kwargs={}, *, daemon=None):
def function():
self.result = target(*args, **kwargs)
super().__init__(group=group, target=function, name=name, daemon=daemon)
def sum_(x, y):
time.sleep(2)
return x + y
def mul_(x, y):
time.sleep(2)
print(x*y)
x = 5
y = 4
t1 = ThreadWithResult(target=sum_, args=(x,y))
t2 = Thread(target=mul_, args=(x,y))
t1.start()
t2.start()
t1.join()
t2.join()
print(t1.result)
import keyboard
from selenium import webdriver
optinos_driver = webdriver.ChromeOptions()
optinos_driver.add_argument("--window-size=1600,1080")
driver = webdriver.Chrome(options = optinos_driver)
driver.get(URL)
keyboard.press('ctrl')
keyboard.send('-')
keyboard.release('ctrl')
vals = pd.Series([1,3,2,5,3,1,2])
fv = 6
def cumscums(vals, fv = fv):
vals_ = []
vals_.append(vals[0])
vals = vals[1:]
for ind,line in enumerate(vals, start=1):
if vals_[ind-1] < fv:
vals_.append(vals_[ind-1] + line)
else:
vals_.append(line)
return vals_
ccc = cumscums(vals, fv = fv)
pd.Series(ccc)
unique_vals_clmn1 = df['column1'].unique().tolist()
df = pd.concat([df[df['column1']==unique_val_clmn1].tail(n=100) for unique_val_clmn1 in unique_vals_clmn1]).reset_index().sort_values('index', ascending=True).set_index('index')