我遇到了一个问题,当从一个浮点数中减去一个数组时,python会自动舍入非常小的数字(小于1e-8).举个例子:
import numpy as np
float(1) - np.array([1e-10, 1e-5])
Run Code Online (Sandbox Code Playgroud)
关于如何强迫python不要圆的任何想法?这迫使我在某些情况下除以零,并成为一个问题.从numpy数组中减去时会出现同样的问题.
我是新用户,使用启动包时遇到问题.我想做的就是使用自举来产生数字向量的均值周围的置信区间,例如:
x <- rnorm(100, 1, .5)
Run Code Online (Sandbox Code Playgroud)
有小费吗?
我是一个新的jquery/js用户试图将一个参数从选择器传递给一个函数.以下是一些代码:
// function to select data
var data = [
{val: 10, year: 1990}, {val: 20, year: 1991}
]
var year_data = []
function select_year_data(y) {
year_data = data.filter(function(d) {return d.year==y})
}
Run Code Online (Sandbox Code Playgroud)
//选择器
<select name="Year" id = "year_menu" style="width: 230px; position: absolute; left: 400px; top: 50px">
<option value=1990>1990</option>
<option value=1991>1991</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我想做的是这样的事情:
<onchange>select_year_data($('#year_menu.val()')
Run Code Online (Sandbox Code Playgroud)
但我知道这不太对.
当我使用相同长度的数组时,我遇到了令人烦恼的形状不匹配问题,但只有一个是宽度一.例如:
import numpy as np
x = np.ones(80)
y = np.ones([80, 100])
x*y
ValueError: shape mismatch: objects cannot be broadcast to a single shape
Run Code Online (Sandbox Code Playgroud)
简单的解决方案是y*x.reshape(x.shape [0],1).但是,我经常最终对数组的一列进行子集化,然后必须指定此重组.有办法避免这种情况吗?
我正在尝试测试对象中的所有值(如果有序)是否是相邻的整数值.例如:
x <- c(1,2,3)
is.adjacent(x)
TRUE
y <- c(1,2,4)
is.adjacent(y)
FALSE
z <- c(4,2,1,3)
is.adjacent(z)
TRUE
Run Code Online (Sandbox Code Playgroud)
对好方法的任何想法?
我试图用1950年的1950 - 2050年每周五的星期五数量计算(我知道,有点晚了).我不熟悉任何日期/日历包使用.有什么想法吗?
这是一个简单的问题,我似乎无法理解 - 我想要做的就是改变页面上元素的位置.我尝试过以下方法:
// Text
body = d3.select('body')
sometext = body.append('text').text('testing') // text appears
// Different Ways i've tried to move it
.attr('cx', 40)
.attr('x', 40)
.attr("transform", "translate("40, 100")
Run Code Online (Sandbox Code Playgroud)
然而,这一切都没有移动文本 - 我缺少什么(http://jsfiddle.net/Hn5JX/)?我有同样的问题在页面上移动svg元素,我只是觉得这在jsfiddle上更容易看到.感谢您提供基本问题的帮助,
转换完成后,我想给对象一个属性.我只是按如下方式更新图像位置:
tmp.transition().duration(1000)
.attr("transform", function(d) {return 'translate(' +
coordinates[d].x +',' +
coordinates[d].y + ')'})
Run Code Online (Sandbox Code Playgroud)
一旦完成,我想给对象tmp一个属性"移动",值为"no".我试过了:
tmp.transition().duration(1000)
.attr("transform", function(d) {return 'translate(' +
coordinates[d].x +',' +
coordinates[d].y + ')'}).end('moved', 'no')
Run Code Online (Sandbox Code Playgroud)
但没有成功.有小费吗?谢谢,
我希望在reveal.js演示文稿中将嵌入式iframe设置为全屏(或全屏的调整百分比). 这个讨论暗示我可以将iframe设置为背景,但这会返回默认背景:
<section data-background="http://viz.healthmetricsandevaluation.org/fgh">
</section>
Run Code Online (Sandbox Code Playgroud)
我也尝试将iframe放在带有类拉伸的div中,但它只占屏幕的一定百分比:
<div class = "stretch">
<iframe width="100%" height="100%" src="http://viz.healthmetricsandevaluation.org/fgh"></iframe>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个 Javascript 函数,该函数将文本写入(最终)创建以下 html 表(我将向其传递不同长度的参数以创建数百个表):
<table>
<tr><td><u>School</u></td>
<td><u>Percent</u></td>
<tr><td>School 1: </td>
<td>Percent1</td></tr>
<tr><td>School 2: </td>
<td>Percent2</td></tr>
<tr><td>School 3: </td>
<td>Percent3</td></tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我拥有的输入是逗号分隔的字符串:
var school_list = "School 1, School 2, School 3"
var pct_list = "Percent1, Percent2, Percent3"
Run Code Online (Sandbox Code Playgroud)
该函数需要传入school_list和pct_list,并返回上述html表格代码的字符串。
javascript ×4
python ×3
d3.js ×2
html ×2
numpy ×2
r ×2
arrays ×1
attributes ×1
calendar ×1
css ×1
date ×1
function ×1
html-table ×1
integer ×1
jquery ×1
menu ×1
presentation ×1
reveal.js ×1
rounding ×1
select ×1
shape ×1
string ×1
subtraction ×1
svg ×1
transition ×1