formula
Excel: Scalar product of two ranges
Use this one =SUMPRODUCT(A1:A3,B1:B3)
How to format a duration as HH:mm?
There is no need to use formulas for that, you can define your own custom formats. Just go to Format -> Number -> More formats -> More date and time formats. It will open a window with several date and time formats to choose from. You can define your own as well, using the upper … Read more
Dynamically evaluate an expression from a formula in Pandas
You can use 1) pd.eval(), 2) df.query(), or 3) df.eval(). Their various features and functionality are discussed below. Examples will involve these dataframes (unless otherwise specified). np.random.seed(0) df1 = pd.DataFrame(np.random.choice(10, (5, 4)), columns=list(‘ABCD’)) df2 = pd.DataFrame(np.random.choice(10, (5, 4)), columns=list(‘ABCD’)) df3 = pd.DataFrame(np.random.choice(10, (5, 4)), columns=list(‘ABCD’)) df4 = pd.DataFrame(np.random.choice(10, (5, 4)), columns=list(‘ABCD’)) 1) pandas.eval This is … Read more
Calculate percentage saved between two numbers?
I know this is fairly old but I figured this was as good as any to put this. I found a post from yahoo with a good explanation: Let’s say you have two numbers, 40 and 30. 30/40*100 = 75. So 30 is 75% of 40. 40/30*100 = 133. So 40 is 133% of 30. … Read more
How to turn a string formula into a “real” formula?
Evaluate might suit: http://www.mrexcel.com/forum/showthread.php?t=62067 Function Eval(Ref As String) Application.Volatile Eval = Evaluate(Ref) End Function
Formula with dynamic number of variables
See ?as.formula, e.g.: factors <- c(“factor1”, “factor2”) as.formula(paste(“y~”, paste(factors, collapse=”+”))) # y ~ factor1 + factor2 where factors is a character vector containing the names of the factors you want to use in the model. This you can paste into an lm model, e.g.: set.seed(0) y <- rnorm(100) factor1 <- rep(1:2, each=50) factor2 <- rep(3:4, … Read more
Convert light frequency to RGB?
Here’s a detailed explanation of the entire conversion process: http://www.fourmilab.ch/documents/specrend/. Source code included!
Formula px to dp, dp to px android
Note: The widely used solution above is based on displayMetrics.density. However, the docs explain that this value is a rounded value, used with the screen ‘buckets’. Eg. on my Nexus 10 it returns 2, where the real value would be 298dpi (real) / 160dpi (default) = 1.8625. Depending on your requirements, you might need the … Read more
Base64 length calculation?
Each character is used to represent 6 bits (log2(64) = 6). Therefore 4 chars are used to represent 4 * 6 = 24 bits = 3 bytes. So you need 4*(n/3) chars to represent n bytes, and this needs to be rounded up to a multiple of 4. The number of unused padding chars resulting … Read more