小编2da*_*aaa的帖子

为什么pandas在非对称误差条的两边应用相同的值?

我正在尝试使用pandas和matplotlib使用以下代码绘制具有不对称误差条的系列:

d = {'high_delta': {1: 0.6,
  2: 0.1,
  3: 0.2,
  4: 0.1,
  5: 0.1,
  6: 0.1,
  7: 0.1,
  8: 0.1,
  9: 0.2,
  10: 0.1},
 'low_delta': {1: 0.2,
  2: 0.1,
  3: 0.1,
  4: 0.1,
  5: 0.1,
  6: 0.1,
  7: 0.1,
  8: 0.1,
  9: 0.1,
  10: 0.4},
 'p_hat': {1: 0.2,
  2: 0.1,
  3: 0.3,
  4: 0.3,
  5: 0.1,
  6: 0.3,
  7: 0.2,
  8: 0.2,
  9: 0.1,
  10: 0.8}}

df = pandas.DataFrame(d)
 df['p_hat'].plot(yerr=df[['low_delta', 'high_delta']].T.values)
(df.p_hat + df.high_delta).plot(style='.')
(df.p_hat - df.low_delta).plot(style='*')
Run Code Online (Sandbox Code Playgroud)

下限似乎总是符合我的预期,但不是在上限添加值,而是再次添加下限的值.

如何将错误传递到matplotlib以便正确呈现错误栏?

matplotlib pandas

6
推荐指数
1
解决办法
605
查看次数

如何让jabber.el不显示用户图标?

我只是将jabber.el设置为与我的Gmail帐户一起使用,我想让它停止在名单中显示用户图标.我只是想看看基本文字.我怎么做?

emacs xmpp

5
推荐指数
2
解决办法
1019
查看次数

为什么使用 Google Cloud Datastore API Explorer 会收到 503 Service Unavailable 错误?

我使用 Google Cloud Console 中的 API Explorer 提交了以下请求:

{
"query": {
"kinds": [
{
"name": "Car"
}
],
"filter": {
"propertyFilter": {
"property": {
"name": "car_name"
},
"operator": "equal",
"value": {
"stringValue": "Honda"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)

我得到了以下回复:

{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "Backend Error"
}
],
"code": 503,
"message": "Backend Error"
}
}
Run Code Online (Sandbox Code Playgroud)

我也通过 OAuth 进行了身份验证。为什么这行不通?

google-app-engine google-cloud-datastore

5
推荐指数
1
解决办法
9572
查看次数

Pandas相当于SQL窗口函数

在Pandas中是否存在与SQL的窗口函数等效的惯用语?例如,在Pandas中写出相当于这个的最紧凑的方法是什么?:

SELECT state_name,  
       state_population,
       SUM(state_population)
        OVER() AS national_population
FROM population   
ORDER BY state_name 
Run Code Online (Sandbox Code Playgroud)

或这个?:

SELECT state_name,  
       state_population,
       region,
       SUM(state_population)
        OVER(PARTITION BY region) AS regional_population
FROM population    
ORDER BY state_name
Run Code Online (Sandbox Code Playgroud)

python sql window-functions pandas

4
推荐指数
1
解决办法
6075
查看次数

如何在Mathematica中进行替换?

我刚刚开始使用Mathematica,我已经得到了关于进行替换的一个非常基本的问题,但我无法让它工作.

我想找到函数phi [x,y]的函数的欧拉 - 拉格朗日方程,然后替换函数phi [x,y]

如果我输入以下内容:

VariationalD[tau*phi[x, y]^2 - 2*phi[x, y]^4 + phi[x, y]^6 + Dot[D[phi[x, y], {{x, y}}], D[phi[x, y, {{x, y}}]]], phi[x, y], {x, y}]

我明白了

Plus[Times[2,tau,phi[x,y]],Times[-8,Power[phi[x,y],3]],Times[6,Power[phi[x,y],5]],Times[-2,Plus[Derivative[0,2][phi][x,y],Derivative[2,0][phi][x,y]]]]
Run Code Online (Sandbox Code Playgroud)

现在如果我尝试% /. phi[x,y] -> phi0[x,y] + psi[x,y]它会替换所有多项式项,但不能用于导数项.

如何强制替换这些函数?

wolfram-mathematica

3
推荐指数
1
解决办法
2291
查看次数

如何计算场的拉普拉斯?

我正在尝试使用scipy.ndimage.convolve计算二维场A的拉普拉斯算子。

stencil = numpy.array([[0, 1, 0],[1, -4, 1], [0, 1, 0]])
scipy.ndimage.convolve(A, stencil, mode='wrap')
Run Code Online (Sandbox Code Playgroud)

但这似乎并没有给我正确的答案。有什么想法我出错了,或者有更好的方法在 numpy 中计算拉普拉斯吗?

python numpy scipy

2
推荐指数
1
解决办法
7208
查看次数

在Incanter中生成随机数

如何在incanter中使用Parallel Colt中的随机数生成器?

我在project.clj文件中列出了这些依赖项:

:dependencies [[org.clojure/clojure"1.2.0"] [org.clojure/clojure-contrib"1.2.0"] [incanter/core"1.2.3"] [incanter/parallelcolt"0.9.4"]]

然后我尝试(导入cern.jet.random.tdouble Normal)并得到一个类java.lang.ClassNotFoundException.

我在这做错了什么?

clojure leiningen incanter

2
推荐指数
2
解决办法
1131
查看次数

如何配置 IntelliJ 以使用 Homebrew 安装的 Java、Scala 和 SBT?

我在运行 Sierra 的 Mac 上使用 IntelliJ CE 2017.2。我已经使用 Homebrew 安装了 Java、Scala 和 SBT,并且我希望在 IntelliJ 中运行的 shell 中拥有相同的环境。如何配置 IntelliJ 以使用现有工具?

scala intellij-idea sbt

2
推荐指数
1
解决办法
831
查看次数

在PostgreSQL上,Pandas to_sql除了'public'之外不能写入架构

我正在尝试将数据框的内容写入除"公共"模式之外的模式中的表.我按照Pandas中描述的模式将数据帧写入其他postgresql模式:

meta = sqlalchemy.MetaData()
engine = create_engine('postgresql://some:user@host/db')
meta = sqlalchemy.MetaData(engine, schema='schema')
meta.reflect(engine, schema='schema')
pdsql = pandas.io.sql.PandasSQLAlchemy(engine, meta=meta)
Run Code Online (Sandbox Code Playgroud)

但是当我试着写到桌子上时:

pdsql.to_sql(df, 'table', if_exists='append')
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

InvalidRequestError: Table 'schema.table' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
Run Code Online (Sandbox Code Playgroud)

我也尝试添加extend_existing=Truereflect通话中,但这似乎没有什么区别.

如何让pandas写入此表?

python sql postgresql sqlalchemy pandas

1
推荐指数
1
解决办法
5311
查看次数