我有一些股票数据,像这样
index=[1,2,3,4,5]
price=[10,11,12,13,14]
Run Code Online (Sandbox Code Playgroud)
我必须使用谷歌可视化绘制该数据的线图,并突出显示(或分散)线上的一些点。例如,要点是:
index=[1,3]
value=[11,13]
Run Code Online (Sandbox Code Playgroud)
我现在有以下代码
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('number',"index");
data.addColumn("number",'price')
data.addRows([
[1, 10],
[2, 11],
[3, 12],
[4, 13],
[5, 14]
]);
// Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
'width':1200,
'height':300, hAxis: {title: 'Year', titleTextStyle: {color: '#333'},
slantedText:true, slantedTextAngle:80},
vAxis: {minValue: 0},
explorer: {
actions: ['dragToZoom', 'rightClickToReset'],
axis: 'horizontal',
keepInBounds: true,
maxZoomIn: 4.0},
colors: ['#D44E41'],};
// Instantiate and draw our chart, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用默认用户模型通过电子邮件过滤来获取 Django 中的特定用户。我在 view.py 中执行以下操作,但它不起作用:
def shareCode(request):
if request.method=="POST":
email = request.POST.get("mail")
print(email)
id = int(request.POST.get('id'))
user = User.objects.get(email = email)
obj = Code.objects.get(pk=id,user = user.id)
res = {"shared":"fasle"}
obj2 = Code(name=obj.name,code=obj.code,shared=True)
obj2.save()
res = {
"shared":True
}
return HttpResponse(json.dumps(res))
Run Code Online (Sandbox Code Playgroud)
模型.py
def shareCode(request):
if request.method=="POST":
email = request.POST.get("mail")
print(email)
id = int(request.POST.get('id'))
user = User.objects.get(email = email)
obj = Code.objects.get(pk=id,user = user.id)
res = {"shared":"fasle"}
obj2 = Code(name=obj.name,code=obj.code,shared=True)
obj2.save()
res = {
"shared":True
}
return HttpResponse(json.dumps(res))
Run Code Online (Sandbox Code Playgroud)
但它出现以下错误
Internal Server Error: …Run Code Online (Sandbox Code Playgroud) 我有以下 numpy 数组
X = np.random.random_integers(100000000,size=(100000000,2))
现在我想添加数组的两列以生成数组的第三列。我正在尝试,X[3] = X[0]+X[1]但它的形状是(2,)。
最终数组示例:
10 5 15
15 6 21
Run Code Online (Sandbox Code Playgroud)