我正在学习弹性搜索,并希望计算不同的值.到目前为止,我可以计算值,但不是很明显.
以下是示例数据:
curl http://localhost:9200/store/item/ -XPOST -d '{
"RestaurantId": 2,
"RestaurantName": "Restaurant Brian",
"DateTime": "2013-08-16T15:13:47.4833748+01:00"
}'
curl http://localhost:9200/store/item/ -XPOST -d '{
"RestaurantId": 1,
"RestaurantName": "Restaurant Cecil",
"DateTime": "2013-08-16T15:13:47.4833748+01:00"
}'
curl http://localhost:9200/store/item/ -XPOST -d '{
"RestaurantId": 1,
"RestaurantName": "Restaurant Cecil",
"DateTime": "2013-08-16T15:13:47.4833748+01:00"
}'
Run Code Online (Sandbox Code Playgroud)
到目前为止我尝试了什么:
curl -XPOST "http://localhost:9200/store/item/_search" -d '{
"size": 0,
"aggs": {
"item": {
"terms": {
"field": "RestaurantName"
}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
输出:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3, …Run Code Online (Sandbox Code Playgroud) 我写了一个程序,我添加了两列并将答案写入CSV文件,但是当我只想编写列的选择时,我收到错误.这是我的逻辑:
import pandas as pd
df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
'foo', 'bar', 'foo', 'bar'],
'B' : ['one', 'one', 'two', 'two',
'two', 'two', 'one', 'two'],
'C' : [56, 2, 3, 4, 5, 6, 0, 2],
'D' : [51, 2, 3, 4, 5, 6, 0, 2]})
grouped = df.groupby(['A', 'B']).sum()
grouped['sum'] = (grouped['C'] / grouped['D'])
# print (grouped[['sum']])
a = pd.DataFrame(grouped)
a.to_csv("C:\\Users\\test\\Desktop\\test.csv", index=False, cols=('A','B','sum'))
Run Code Online (Sandbox Code Playgroud)
我怎么才能写出A,B和Sum列的数据.我收到以下错误
Traceback (most recent call last):
File "C:\Users\test\Desktop\eclipse\yuy\group.py", line 19, in <module>
a.to_csv("C:\\Users\\test\\Desktop\\test.csv", index=False, cols=('A','B','sum')) …Run Code Online (Sandbox Code Playgroud) 我会说我不是VBA的专家.我有一个VBA代码,它在一个单元格中附加选定列表中的多个值.代码有效,但现在我想将代码应用于多个单元格.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
'Code by Sumit Bansal from https://trumpexcel.com
' To Select Multiple Items from a Drop Down List in Excel
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
If Target.Address = "$A$7" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = …Run Code Online (Sandbox Code Playgroud) 嗨,我是bash编程的新手,我正在读代码,但我无法理解一件事.-gt在这段代码中意味着什么
if [ $result -gt 0 ] ;
then
exit 1 ;
fi
Run Code Online (Sandbox Code Playgroud)