structure(list(ticker = c("WMT", "WMT", "WMT", "WMT", "WMT",
"WMT"), filingdate = structure(c(18551, 18551, 18551, 18537,
18536, 18534), class = "Date"), formtype = c("4", "4", "4", "4",
"4", "4"), issuername = c("WALMART INC", "WALMART INC", "WALMART INC",
"WALMART INC", "WALMART INC", "WALMART INC"), ownername = c("LORE MARC E",
"LORE MARC E", "LORE MARC E", "BIGGS M BRETT", "LORE MARC E",
"WALTON ALICE L"), officertitle = c("Executive Vice President",
"Executive Vice President", "Executive Vice President", "Executive Vice President",
"Executive Vice President", NA), isdirector = c("N", "N", "N",
"N", "N", "N"), isofficer = c("Y", "Y", "Y", "Y", "Y", "N"),
istenpercentowner = c("N", "N", "N", "N", "N", "Y"), transactiondate = structure(c(18549,
18549, 18549, 18536, 18534, 18534), class = "Date"), securityadcode = c("ND",
"ND", "ND", "ND", "ND", "ND"), transactioncode = c("S", "S",
"S", "F", "F", "S"), sharesownedbeforetransaction = c(1669368,
1610399, 1591019, 302554, 1707160, 389404553), transactionshares = c(-58969,
-19380, -6651, -657, -37792, -606875), sharesownedfollowingtransaction = c(1610399,
1591019, 1584368, 301897, 1669368, 388797678), transactionpricepershare = c(144.114,
145.409, 145.891, 139.91, 137.25, 137.049), transactionvalue = c(8498258,
2818026, 970321, 91921, 5186952, 83171612), securitytitle = c("Common",
"Common", "Common", "Common Stock", "Common", "Common Stock"
), directorindirect = c("D", "D", "D", "D", "D", "I"), natureofownership = c(NA,
NA, NA, NA, NA, "By Trust"), dateexercisable = structure(c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), class = "Date"),
priceexercisable = c(NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_), expirationdate = structure(c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), class = "Date"),
rownum = c(1, 2, 3, 1, 1, 2), mycolumn = c(-8498258, -2818026,
-970321, -91921, -5186952, -83171612)), row.names = c(1L,
2L, 3L, 9L, 13L, 15L), class = "data.frame")
我想压缩我的数据框以对“ filingdate”列每一天的“ my column”列中的所有值求和。 例如,一天2020-10-16重复3次。我希望新的data.frame包含一行日期为2020-10-16的行,而“我的列”列是其3个值的总和。 其他所有列都可以删除,也可以保留最后一天的值。
所有其他日期都一样
答案 0 :(得分:0)
一个选项可以是const canvas = document.createElement('canvas');
canvas.width = tensor.shape.width
canvas.height = tensor.shape.height
await tf.browser.toPixels(tensor, canvas);
:
aggregate()
输出:
#Code 1
newdf <- aggregate(mycolumn~filingdate,data=df,sum,na.rm=T)
或使用 filingdate mycolumn
1 2020-09-29 -83171612
2 2020-10-01 -5186952
3 2020-10-02 -91921
4 2020-10-16 -12286605
:
dplyr
输出:
library(dplyr)
#Code 2
newdf <- df %>% group_by(filingdate) %>% summarise(mycolumn=sum(mycolumn,na.rm=T))