concat() 得到了一个意外的关键字参数“join_axes”

我正在尝试在 Google Colab 的 ipynb 中使用 pymc3。


这是我的代码:


regression_conjugate = pm.Model()

with regression_conjugate:

  sigma2 = pm.InverseGamma("sigma2",alpha = 0.5*nu0,beta=0.5*lam0)

  sigma = pm.math.sqrt(sigma2)

  a = pm.Normal("a",mu = b0[0],sd = sigma*sd0[0])

  b = pm.Normal("b",mu = b0[1],sd = sigma*sd0[1])

  y_hat = a+b*x

  likelihood = pm.Normal("y",mu = y_hat,sd = sigma,observed = y)


n_draws = 50

n_chains = 4

n_tune = 1000

with regression_conjugate:

  trace = pm.sample(draws = n_draws, chains=n_chains,tune=n_tune,random_seed=123)


print(pm.summary(trace))

但是,这会输出以下内容:


TypeError                                 Traceback (most recent call last)

<ipython-input-44-4e1a1fef1a74> in <module>()

     26   trace = pm.sample(draws = n_draws, chains=n_chains,tune=n_tune,random_seed=123)

     27 

---> 28 print(pm.summary(trace))


TypeError: concat() got an unexpected keyword argument 'join_axes'

如果有人理解,请告诉我。


pymc3:3.7


熊猫:1.0.3


慕桂英3389331
浏览 791回答 4
4回答

翻阅古今

由于某种原因,“join_axes”在 0.25 版中已被弃用。您可以通过重新索引来实现相同的效果。#won't work:df3 = pd.concat([df1, df2], axis=1,join_axes=[df1.index]) #won't work#instead:df3 = pd.concat([df1, df2], axis=1)df3 = df3.reindex(df1.index)

米琪卡哇伊

另一方面,如果您来到这里是因为您尝试将 join_axes 与列一起使用,请尝试以下操作:# the columns of df3 and only the columns of df4 that are commondf_new = pd.concat([df3, df4], axis=1)df_new[df3.columns]用 df3 作为&nbsp; &nbsp; C&nbsp; &nbsp;D&nbsp; &nbsp;E&nbsp;0&nbsp; C1&nbsp; D1&nbsp; E1&nbsp;1&nbsp; C2&nbsp; D2&nbsp; E2&nbsp;2&nbsp; C3&nbsp; D3&nbsp; E3和 df4 作为&nbsp; &nbsp; D&nbsp; &nbsp;E&nbsp; &nbsp;F&nbsp;0&nbsp; D5&nbsp; E5&nbsp; F5&nbsp;1&nbsp; D6&nbsp; E6&nbsp; F6&nbsp;2&nbsp; D7&nbsp; E7&nbsp; F7将产生的结果是&nbsp; &nbsp; C&nbsp; &nbsp;D&nbsp; &nbsp;D&nbsp; &nbsp;E&nbsp; &nbsp;E&nbsp;0&nbsp; C1&nbsp; D1&nbsp; D5&nbsp; E1&nbsp; E5&nbsp;1&nbsp; C2&nbsp; D2&nbsp; D6&nbsp; E2&nbsp; E6&nbsp;2&nbsp; C3&nbsp; D3&nbsp; D7&nbsp; E3&nbsp; E7

叮当猫咪

“join_axes”函数已弃用。作为我的研究结果,我得出以下结论;代替:pd.concat&nbsp;([df1,&nbsp;df2],&nbsp;join_axes&nbsp;=&nbsp;[df1.columns])你可以试试这个:pd.concat([df1,&nbsp;df2.reindex(columns&nbsp;=&nbsp;df1.columns)],&nbsp;ignore_index&nbsp;=&nbsp;True)

白猪掌柜的

正如渡边彰久在评论中所说,将 PyMC3 升级到 3.8 版解决了这个问题。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python