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

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 Bond… Read More ValueError: At least one array required as input error when dividing the set

writing a if-else-then fucntion

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 optionstrat… Read More writing a if-else-then fucntion

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

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, 2022],… Read More unique value counts of products purchased by the customer in previous year