所以我有一个包含这种形式数据的对象:
{key1: val1, key2: val2}
我想以某种方式转换为以下内容:
{first: {key1:[], val1:[]},
second: {key2:[], val2:[]} };
我试过
object = {key1: val1, key2: val2};
var array = {};
var cc=0;
for (var prop in object){
var ob_prop = object[prop];
if(cc) array['first'] = {prop:[], ob_prop:[]};
else array['second'] = {prop:[],ob_prop:[]};
cc++;
}
但我得到了
{ second: { prop: [], ob_prop: [] },
first: { prop: [], ob_prop: [] } }
答案 0 :(得分:1)
如Felix Kling的评论中所述,请尝试:#standardSQL
SELECT AVG(temp) avg_temp, _TABLE_SUFFIX y
FROM `bigquery-public-data.noaa.gsod_20*` #every year that starts with "20"
WHERE _TABLE_SUFFIX BETWEEN "10" AND "14" #only years between 2010 and 2014
GROUP BY y
ORDER BY y