我有一个1维数组,我可以计算这个样本的"均值"和"标准偏差"并绘制"正态分布",但我有一个问题:
我想在下图中绘制数据和正态分布:
我不知道如何绘制"数据"和"正态分布"
关于"scipy.stats中的高斯概率密度函数"的任何想法?
s = np.std(array)
m = np.mean(array)
plt.plot(norm.pdf(array,m,s))
Run Code Online (Sandbox Code Playgroud) 请帮我绘制下面数据的正态分布:
数据:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
h = [186, 176, 158, 180, 186, 168, 168, 164, 178, 170, 189, 195, 172,
187, 180, 186, 185, 168, 179, 178, 183, 179, 170, 175, 186, 159,
161, 178, 175, 185, 175, 162, 173, 172, 177, 175, 172, 177, 180]
std = np.std(h)
mean = np.mean(h)
plt.plot(norm.pdf(h,mean,std))
Run Code Online (Sandbox Code Playgroud)
输出:
Standard Deriviation = 8.54065575872
mean = 176.076923077
Run Code Online (Sandbox Code Playgroud)
情节不正确,我的代码出了什么问题?
我有两个数组:
数组1:
[
{ id: "abdc4051", date: "2017-01-24" },
{ id: "abdc4052", date: "2017-01-22" }
]
Run Code Online (Sandbox Code Playgroud)
和数组2:
[
{ id: "abdc4051", name: "ab" },
{ id: "abdc4052", name: "abc" }
]
Run Code Online (Sandbox Code Playgroud)
我需要基于这两个数组合并id并得到这个:
[
{ id: "abdc4051", date: "2017-01-24", name: "ab" },
{ id: "abdc4052", date: "2017-01-22", name: "abc" }
]
Run Code Online (Sandbox Code Playgroud)
如何在不迭代的情况下做到这一点Object.keys?
我想用python连接到IB,这是我的代码:
from ib.ext.Contract import Contract
from ib.ext.Order import Order
from ib.opt import Connection, message
def error_handler(msg):
print "Server Error: %s" % msg
def reply_handler(msg):
print "Server Response: %s, %s" % (msg.typeName, msg)
if __name__ == "__main__":
tws_conn = Connection.create(port=7496, clientId=100)
tws_conn.connect()
tws_conn.register(error_handler, 'Error')
tws_conn.registerAll(reply_handler)
Run Code Online (Sandbox Code Playgroud)
每当我使用此代码时,我收到此错误,表示我无法连接到服务器:
Server Error: <error id=-1, errorCode=504, errorMsg=Not connected>
Server Response: error, <error id=-1, errorCode=504, errorMsg=Not connected>
Run Code Online (Sandbox Code Playgroud)
为什么我无法连接到IB?
我想知道什么是最好的方法来知道手机号码是否已经注册到Telegram信使?
谢谢.
我有一个包含 100 万行的大型 .xlsx 文件。我不想一次性打开整个文件。我想知道是否可以读取文件的一部分,处理它,然后读取下一个块?(我更喜欢使用 pandas。)
我有一个包含一些布尔值的对象,如下所示:
{ date: "2017-10-05", name_change: false, age_change: true, ... }
Run Code Online (Sandbox Code Playgroud)
我想要filter()那些真实的钥匙。我还需要日期值。我该怎么做这个filter?
问候。
我正在将Material-UI(版本 v0.20.1)与 ReactJS(版本 15.5)一起使用。这段代码应该可以工作,但事实并非如此。我总是以相同的方式使用 TextField,但在新组件中,我无法在输入中输入任何内容,并且 onChange() 没有触发。可能的原因是什么?甚至 onChange() 中的“console.log”也没有出现!!!
import TextField from 'material-ui/TextField';
class Nav extends Component {
constructor() {
super();
this.state = {
searchValue: '',
}...
Run Code Online (Sandbox Code Playgroud)
我像往常一样使用 TextField:
<TextField
value={this.state.searchValue}
onChange={(event, value) => {
this.setState({ searchValue: value });
}}
/>
Run Code Online (Sandbox Code Playgroud) 这是我的WTForm
from flask.ext.wtf import Form
from wtforms import TextField, PasswordField, SelectMultipleField,HiddenField,validators
from wtforms.validators import Required, Email, EqualTo
class CreateCar(Form):
id = HiddenField ('id')
plaque_no = TextField('plaque_no', [Required(message='pn')])
plaque_img = TextField('plaque_img', [Required(message='pi')])
Run Code Online (Sandbox Code Playgroud)
这是我的Flask视图:
def manage(task=None,id=None):
form = CreateCar
return render('MyHTML.html', form=form)
Run Code Online (Sandbox Code Playgroud)
每当我试图通过这个来覆盖我的表单字段时:
{% for item in form %}
{{ item }}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
TypeError: 'FormMeta' object is not iterable
Run Code Online (Sandbox Code Playgroud)
我的表格有什么问题?谢谢
在ReactJS中,我将路由更改为具有"id"的新路由,然后基于此"id",我必须调用API并获取数据.
我已经使用了API调用componentDidMount,componentWillMount并试图setState()让我的数据处于状态.但他们在我的情况下不起作用.
问题在于,render()当我想使用我的数据(来自状态)时,数据不存在,因为API调用需要一些时间来更新状态.
这是我的代码:
componentDidMount() {
api.get(id).then((response) => {
this.setState({response,});
});
Run Code Online (Sandbox Code Playgroud)
有了这种方法,我没有我想要的数据(渲染方法),它最终会处于状态但为时已晚!
如何更改修复加载问题的方法?
我必须获取一些数据componentWillMount(),这需要一些时间(2秒),之后,我setState用来更新状态中的一些值,因为这会setState重新呈现UI,组件初始渲染和渲染之间存在延迟从setState,有没有办法解决这个UI滞后?
更新:如果我想使用加载指示器,我应该把它放在哪里?我使用承诺来获取我的数据,如下所示:
componentDidMount() {
api.getData().then((response) => { ... }
Run Code Online (Sandbox Code Playgroud) 当我将 aternary statement或 anif statement放入 Object.keys() 中时,如下所示:
Object.keys(date).forEach((index) => {
dates[date[index].id] !== undefined ?
dates[date[index].id] =
[...dates[dates[date[index].id], dates[date[index].name]
: null;
});
Run Code Online (Sandbox Code Playgroud)
我从 Linter 收到此错误:
Expected an assignment or function call and instead saw an expression. (no-unused-expressions)
Run Code Online (Sandbox Code Playgroud)
当我使用常规 if 语句时,出现此错误,
Parsing error: Unexpected token (Fatal)
Run Code Online (Sandbox Code Playgroud)
为什么?
我做了一些这样的 MongoDB 聚合:
db.first_collection.aggregate(
[
{ $lookup: {
from:"second_collection",
localField:"fisrt_id",
foreignField:"second_id",
as:"result"
}
},
{ $redact: {
$cond: {
if: { "$eq": [ "$result", [] ] },
then: "$$DESCEND",
else: "$$PRUNE"
}
}
},
]
)
Run Code Online (Sandbox Code Playgroud)
输出是:
{ "_id" : ObjectId("5a32249969e74c004161acc8"), "name" : "n1", "createdAt" : ISODate("2017-12-14T07:13:28.048Z"), "updatedAt" : ISODate("2017-12-14T07:13:28.048Z"), "result" : [ ] }
{ "_id" : ObjectId("5a69a60382e7d3002e6c7c74"), "name" : "n2", "createdAt" : ISODate("2018-01-25T09:40:19.098Z"), "updatedAt" : ISODate("2018-01-25T09:43:46.508Z"), "result" : [ ] }
Run Code Online (Sandbox Code Playgroud)
而不是Objects,我需要一个仅包含 ID 的数组。喜欢:
["5a32249969e74c004161acc8", "5a69a60382e7d3002e6c7c74"] …Run Code Online (Sandbox Code Playgroud) python ×5
reactjs ×5
javascript ×3
ecmascript-6 ×2
matplotlib ×2
numpy ×2
react-native ×2
scipy ×2
flask ×1
ibpy ×1
jinja2 ×1
material-ui ×1
mongodb ×1
pandas ×1
plot ×1
telegram ×1
telegram-bot ×1
wtforms ×1