concat() got an unexpected keyword argument 'join_axes'
Asked Answered
S

4

5

I am trying to use pymc3 in an ipynb on Google Colab.

Here is my code:

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))

However, this outputs the following:

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'

please let me know if anyone who understands.

pymc3 : 3.7

pandas : 1.0.3

Strachey answered 22/4, 2020 at 10:32 Comment(3)
I tried to run PyMC3 but got an Compiler Deprecated error. Turns out you might be using newer version of Python3 than Theano compiler which needs to be configured for PyMC3 can support. Read this. Try to edit your post with more information and code that can be run. You are also missing import statements.Turgor
What happens if you just do pm.summary(trace) without the print?Manufactory
I'm sorry for the lack of information. I tried to upgrade version of pymc3 to 3.8 which is the latest version. So this problem has been solved. Thank you so much!Ernestineernesto
A
5

"join_axes" was deprecated in version 0.25 for some reason. You can achieve the same effect by reindexing.

#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)
Arela answered 2/10, 2020 at 17:8 Comment(0)
L
1

On the other hand, if you came here because you tried to used join_axes with columns, try this instead:

# the columns of df3 and only the columns of df4 that are common
df_new = pd.concat([df3, df4], axis=1)
df_new[df3.columns]

With df3 as

    C   D   E
 0  C1  D1  E1
 1  C2  D2  E2
 2  C3  D3  E3

and df4 as

    D   E   F
 0  D5  E5  F5
 1  D6  E6  F6
 2  D7  E7  F7

the result that will be produced is

    C   D   D   E   E
 0  C1  D1  D5  E1  E5
 1  C2  D2  D6  E2  E6
 2  C3  D3  D7  E3  E7
Listlessness answered 16/8, 2021 at 14:54 Comment(0)
D
0

As 渡邊彰久 said in the comments upgrading PyMC3 to version 3.8 solved the problem.

Debauchee answered 10/6, 2020 at 9:21 Comment(0)
M
0

The "join_axes" function is deprecated. As a result of my research, I came to the following;

instead of:

pd.concat ([df1, df2], join_axes = [df1.columns])

You can try this:

pd.concat([df1, df2.reindex(columns = df1.columns)], ignore_index = True)
Monogram answered 1/7, 2021 at 15:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.