apply

views

纵然是瞬间 提交于 2019-11-26 12:53:31
common.Views V$LOG 显示控制文件里online redo logfile的信息 GROUP# Log group number THREAD# Log thread number SEQUENCE# Log sequence number BYTES Size of the log (in bytes) BLOCKSIZE Block size of the logfile (512 or 4096),细粒度,datafile的blocksize为8192,粗粒度 MEMBERS Number of members in the log group ARCHIVED Archive status (YES) or (NO) STATUS Log status: UNUSED - Online redo log has never been written to.通常指从未被使用的日志组,即新添加的日志组 CURRENT - Current redo log. This implies that the redo log is active. The redo log could be open or closed.LGWR进程正把redo log buffer的日志写进日志组中,在进行实例恢复时是必须的 ACTIVE Log is active but is

Why does pandas apply calculate twice

╄→尐↘猪︶ㄣ 提交于 2019-11-26 12:42:40
问题 I\'m using the apply method on a panda\'s DataFrame object. When my DataFrame has a single column, it appears that the applied function is being called twice. The questions are why? And, can I stop that behavior? Code: import pandas as pd def mul2(x): print \'hello\' return 2*x df = pd.DataFrame({\'a\': [1,2,0.67,1.34]}) print df.apply(mul2) Output: hello hello 0 2.00 1 4.00 2 1.34 3 2.68 I\'m printing \'hello\' from within the function being applied. I know it\'s being applied twice because

How does require() in node.js work?

我与影子孤独终老i 提交于 2019-11-26 12:06:21
问题 I tried this: // mod.js var a = 1; this.b = 2; exports.c = 3; // test.js var mod = require(\'./mod.js\'); console.log(mod.a); // undefined console.log(mod.b); // 2 console.log(mod.c); // 3, so this === exports? So I image that require() may be implement like this: var require = function (file) { var exports = {}; var run = function (file) { // include \"file\" here and run }; run.apply(exports, [file]); return exports; } Is that right? Please help me to understand require(), or where can I

Why does df.apply(tuple) work but not df.apply(list)?

最后都变了- 提交于 2019-11-26 11:35:14
问题 Here\'s a dataframe: A B C 0 6 2 -5 1 2 5 2 2 10 3 1 3 -5 2 8 4 3 6 2 I could retrieve a column which is basically a tuple of columns from the original df using df.apply : out = df.apply(tuple, 1) print(out) 0 (6, 2, -5) 1 (2, 5, 2) 2 (10, 3, 1) 3 (-5, 2, 8) 4 (3, 6, 2) dtype: object But if I want a list of values instead of a tuple of them, I can\'t do it, because it doesn\'t give me what I expect: out = df.apply(list, 1) print(out) A B C 0 6 2 -5 1 2 5 2 2 10 3 1 3 -5 2 8 4 3 6 2 Instead, I

Sum every nth points

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 10:59:03
问题 I have a vector and I need to sum every n numbers and return the results. This is the way I plan on doing it currently. Any better way to do this? v = 1:100 n = 10 sidx = seq.int(from=1, to=length(v), by=n) eidx = c((sidx-1)[2:length(sidx)], length(v)) thesum = sapply(1:length(sidx), function(i) sum(v[sidx[i]:eidx[i]])) This gives: thesum [1] 55 155 255 355 455 555 655 755 855 955 回答1: unname(tapply(v, (seq_along(v)-1) %/% n, sum)) # [1] 55 155 255 355 455 555 655 755 855 955 回答2: UPDATE: If

Remove/collapse consecutive duplicate values in sequence

左心房为你撑大大i 提交于 2019-11-26 09:45:36
问题 I have the following dataframe : a a a b c c d e a a b b b e e d d The required result should be a b c d e a b e d It means no two consecutive rows should have same value. How it can be done without using loop. As my data set is quite huge, looping is taking lot of time to execute. The dataframe structure is like the following a 1 a 2 a 3 b 2 c 4 c 1 d 3 e 9 a 4 a 8 b 10 b 199 e 2 e 5 d 4 d 10 Result: a 1 b 2 c 4 d 3 e 9 a 4 b 10 e 2 d 4 Its should delete the entire row. 回答1: One easy way is

Concatenate row-wise across specific columns of dataframe

放肆的年华 提交于 2019-11-26 09:31:11
问题 I have a data frame with columns that, when concatenated (row-wise) as a string, would allow me to partition the data frame into a desired form. > str(data) \'data.frame\': 680420 obs. of 10 variables: $ A : chr \"2011-01-26\" \"2011-01-26\" \"2011-02-09\" \"2011-02-09\" ... $ B : chr \"2011-01-26\" \"2011-01-27\" \"2011-02-09\" \"2011-02-10\" ... $ C : chr \"2011-01-26\" \"2011-01-26\" \"2011-02-09\" \"2011-02-09\" ... $ D : chr \"AAA\" \"AAA\" \"BCB\" \"CCC\" ... $ E : chr \"A00001\" \

Apply a function to every row of a matrix or a data frame

你说的曾经没有我的故事 提交于 2019-11-26 08:55:15
问题 Suppose I have a n by 2 matrix and a function that takes a 2-vector as one of its arguments. I would like to apply the function to each row of the matrix and get a n-vector. How to do this in R? For example, I would like to compute the density of a 2D standard Normal distribution on three points: bivariate.density(x = c(0, 0), mu = c(0, 0), sigma = c(1, 1), rho = 0){ exp(-1/(2*(1-rho^2))*(x[1]^2/sigma[1]^2+x[2]^2/sigma[2]^2-2*rho*x[1]*x[2]/(sigma[1]*sigma[2]))) * 1/(2*pi*sigma[1]*sigma[2]

Calculate row-wise proportions

这一生的挚爱 提交于 2019-11-26 08:29:31
问题 I have a data frame: x <- data.frame(id = letters[1:3], val0 = 1:3, val1 = 4:6, val2 = 7:9) # id val0 val1 val2 # 1 a 1 4 7 # 2 b 2 5 8 # 3 c 3 6 9 Within each row, I want to calculate the corresponding proportions (ratio) for each value. E.g. for the value in column \"val0\", I want to calculate row-wise val0 / (val0 + val1 + val2). Desired output: id val0 val1 val2 1 a 0.083 0.33 0.583 2 b 0.133 0.33 0.533 3 c 0.167 0.33 0.5 Can anyone tell me what\'s the best way to do this? Here it\'s

apply a function over groups of columns

时光怂恿深爱的人放手 提交于 2019-11-26 08:24:55
问题 How can I use apply or a related function to create a new data frame that contains the results of the row averages of each pair of columns in a very large data frame? I have an instrument that outputs n replicate measurements on a large number of samples, where each single measurement is a vector (all measurements are the same length vectors). I\'d like to calculate the average (and other stats) on all replicate measurements of each sample. This means I need to group n consecutive columns