-1
def chek_stationary(x):
    result=adfuller(x)
    label=['ADF statestic test','p value','num of legs','num of observation']
    for value,label in zip(result,label):
        print(label + ":" + result)
    if result[1] <= 0.05 :
        print ('there is evedincee null hypothesis')
        print('which means there is no root here ')
        print ('and its  stationary ')
    else :
        print ('there isnot evedence and there is root and its nun stationrary')

Whenever I tried this function, I got this error: "can only concatenate str (not "tuple") to str"

What should I do ?

quamrana
  • 37,849
  • 12
  • 53
  • 71
arminius
  • 3
  • 1
  • 2
  • 1
    "what should i do ?" -- not concatenate two objects together when one is a string but one isn't? If you want more specific help, please post a [mcve], one with a clear statement of intended output and information about which line is throwing the error. – John Coleman Sep 02 '21 at 10:21
  • result appears to be a tuple. You can cast it to a string `str(result)` or choose the element of the tuple to print `result[0]`. – Daniel Lee Sep 02 '21 at 10:27
  • Did you mean: `print(label + ":" + value)`? – quamrana Sep 02 '21 at 10:36

1 Answers1

0

Example of your situation:

str_var = 'aaa'
tuple_var = ('b','B')
print(str_var  + ":" +  tuple_var)

Result with the same error thrown: TypeError: can only concatenate str (not "tuple") to str

Fix: - just add str() function before.

str_var = 'aaa'
tuple_var = ('b','B')
print(str_var  + ":" +  str(tuple_var))

Result without error: aaa:('b', 'B')

Niv Dudovitch
  • 1,614
  • 7
  • 15