我正在尝试将列unixtime数据转换为'YYYY-MM-DD'格式,但没有得到。我的列的数据类型为数字。
我尝试了以下查询,但出现错误:
select to_timestamp(starttime,'YYYY-MM-DD') , count(*) from cdrs_052019 group by 1
查询执行失败
原因:SQL错误[42883]:错误:函数to_timestamp(数字, 未知)不存在提示:没有函数与给定名称匹配,并且 参数类型。您可能需要添加显式类型转换。位置: 8
|starttime |endtime |duration|duration_min|
|----------|----------|--------|------------|
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694959 |1 | |
需要以下格式的结果:
starttime | count(*)
2019-05-01 56666
2019-05-02 77777
2019-05-03 69495
2019-05-04 4447
答案 0 :(得分:0)
好的,您可以通过 Dictionary<int, int> occurences = new Dictionary<int, int>();
foreach (int i in modeList)
{
if (occurences.ContainsKey(i))
{
occurences[i]++;
}
else
{
occurences.Add(i, 1);
}
}
var maxNumberOfOccurences =occurences.Values.Max();
将时间戳转换为日期类型,如下所示:
df = pd.DataFrame({
'A':[5,3,6,9,2,4],
'B':[4,5,4,5,5,4],
'C':[7,8,9,4,2,3],
'D':[1,3,5,7,1,0],
})
from itertools import chain, combinations
def all_subsets(ss):
return chain(*map(lambda x: combinations(ss, x), range(1, len(ss)+1)))
#get all combination
tups = list(all_subsets(df.columns))
#for each combination multiple values
df1 = pd.concat([df.loc[:,c].product(axis=1) for c in tups], axis=1)
#set new columns by join list of tuples tups
df1.columns = [''.join(x) for x in tups]
print (df1)
A B C D AB AC AD BC BD CD ABC ABD ACD BCD ABCD
0 5 4 7 1 20 35 5 28 4 7 140 20 35 28 140
1 3 5 8 3 15 24 9 40 15 24 120 45 72 120 360
2 6 4 9 5 24 54 30 36 20 45 216 120 270 180 1080
3 9 5 4 7 45 36 63 20 35 28 180 315 252 140 1260
4 2 5 2 1 10 4 2 10 5 2 20 10 4 10 20
5 4 4 3 0 16 12 0 12 0 0 48 0 0 0 0
您想要的最终SQL:
::date