有几个R数据帧具有相同的两列:" YMD"," Amount"如下
a <- data.frame(YMD = as.Date(c("2012-02-01", "2014-03-04", "2015-05-08")), Amount = c(100, 200, 300))
b <- data.frame(YMD = as.Date(c("2012-02-01", "2013-11-08", "2016-09-01")), Amount = c(10, 20, 30))
c <- data.frame(YMD = as.Date(c("2013-04-10", "2013-11-08", "2016-09-01")), Amount = c(1, 2, 3))
> a
YMD Amount
1 2012-02-01 100
2 2014-03-04 200
3 2015-05-08 300
> b
YMD Amount
1 2012-02-01 10
2 2013-11-08 20
3 2016-09-01 30
> c
YMD Amount
1 2013-04-10 1
2 2013-11-08 2
3 2016-09-01 3
请教我如何在上述3个数据框中应用某种附加功能时获得以下结果
YMD Amount
1 2012-02-01 110
2 2013-11-08 22
3 2014-03-04 200
4 2015-05-08 300
5 2016-09-01 33
谢谢!
答案 0 :(得分:1)
我们可以在import spacy
from nltk import Tree
en_nlp = spacy.loads('en')
doc = en_nlp("The quick brown fox jumps over the lazy dog.")
def to_nltk_tree(node):
if node.n_lefts + node.n_rights > 0:
return Tree(node.orth_, [to_nltk_tree(child) for child in node.children])
else:
return node.orth_
[to_nltk_tree(sent.root).pretty_print() for sent in doc.sents]
中放置'data.frame'之后使用rbindlist
中的data.table
,然后按'YMD'分组,我们得到list
'量'
sum
或使用library(data.table)
rbindlist(list(a,b,c))[, .(Amount = sum(Amount)), by = YMD]
# YMD Amount
#1: 2012-02-01 110
#2: 2014-03-04 200
#3: 2015-05-08 300
#4: 2013-11-08 22
#5: 2016-09-01 33
#6: 2013-04-10 1
,我们可以对dplyr
和bind_rows
summarise
答案 1 :(得分:0)
我会做这样的事情:
document.onkeydown = function (e) {
e = e || window.event;
switch (e.which || e.keyCode) {
case 13 : //Your Code Here (13 is ascii code for 'ENTER')
break;
}
}