首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GDELT:统计特定主题的出现次数

GDELT:统计特定主题的出现次数
EN

Stack Overflow用户
提问于 2020-11-10 17:25:51
回答 1查看 88关注 0票数 1

我正在尝试计算术语“比特币”在GDELT数据库的主题列中出现的频率,然后按日期对计数进行分组。这是我到目前为止所知道的:

代码语言:javascript
复制
SELECT DATE, SPLIT(RTRIM(Themes,';'),';') themes 

FROM `gdelt-bq.gdeltv2.gkg_partitioned` WHERE _PARTITIONTIME >= "2020-11-01 00:00:00" AND _PARTITIONTIME < "2020-11-07 00:00:00" 
#and (Themes like "%BITCOIN%")
#or (AllNames like "%bitcoin%" or AllNames like "%BITCOIN%")

and length(Themes) > 1
) select count(theme) cnt from nested, UNNEST(themes) as theme WHERE theme like "%BITCOIN%"

group by DATE

这是正确的方法吗?谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-11 05:10:55

下面是针对BigQuery标准SQL的说明

代码语言:javascript
复制
#standardsql
select date(_partitiontime) date, count(theme) occurences
from `gdelt-bq.gdeltv2.gkg_partitioned`, unnest(split(themes,';')) as theme 
where _partitiontime >= "2020-11-01 00:00:00" and _partitiontime < "2020-11-07 00:00:00" 
and lower(theme) like "%bitcoin%"
group by date
-- order by date  

with output

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64766110

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档