How can I write a function that finds any and all elements of a list that add to a target?

Advertisements I have been hired to reconcile years of financial records that have quite large discrepancies. The statements are listed in excel and include a name and figure of the transaction (either positive or negative for credit/debit). I’ve been asked to manually read through all the statements to find any combination of values that would… Read More How can I write a function that finds any and all elements of a list that add to a target?

ValueError: At least one array required as input error when dividing the set

Advertisements I work on a finance forecasting project I did my preprocessing part but when I try to construct train and test set I got an error I have constructed my DataFrame as alldata = pd.DataFrame({‘Date’:date, ‘S&P 500 Price’:normalised_snp, ‘S&P 500 Open’: normalised_snpopen, ’10 Year Bond Price’: normalised_tybp, ’10 Year Bond Open’: normalised_tybpopen, ‘2 Year… Read More ValueError: At least one array required as input error when dividing the set

writing a if-else-then fucntion

Advertisements I am trying to write a function to call a function from a package, snippets as below: library(optionstrat) # sameple detla # do not run # calldelta(s,x,sigma,t,r) # putdelta(s,x,sigma,t,r) x=10 sigma=0.25 t=0.25 r=0.05 delta<-function(option_type,stock_price) { if (option_type="c") { delta<-calldelta(s,x,sigma,t,r) } else { delta<-putdelta(s,x,sigma,t,r) } } both calldelta and putdelta are built in functions from… Read More writing a if-else-then fucntion

unique value counts of products purchased by the customer in previous year

Advertisements I am building a function that creates an aggregate table with certain variables developed from df. I think I got most things right, but I am struggling understanding how to count a number of distinct products bought by the customer in previous year. Example of my df: df = pd.DataFrame({‘year’: [2020, 2021, 2021, 2021,… Read More unique value counts of products purchased by the customer in previous year