# 'tuple' object is not callable while reshaping training data using python

I have data csv file with three inputs names temperature, humidity, wind. Here I want to predict temperature value in every 60 minute using LSTM model.

Here I write the code to reshape the train . But I got an error tuple' object is not callable

My code:

data = pd.read_csv('data6.csv' )
data['date'] = pd.to_datetime(data['date'] + " " + data['time'], format='%m/%d/%Y %H:%M:%S')
data.set_index('date', inplace=True)
data = data.values

scaler = MinMaxScaler(feature_range=(0, 1))
data = scaler.fit_transform(data)

train_size = int(len(data) * 0.67)
test_size = len(data) - train_size
train, test = data[0:train_size,:], data[train_size:len(data),:]

X = 1
n_out = 1

x,y=[],[]
start =0
data = train.reshape(train.shape(train.shape[0] ,3, train.shape[1]))
for _ in range(len(data)):
in_end = start+X
out_end= in_end + n_out
if out_end < len(data):
x_input = data[start:in_end]
x.append(x_input)
y.append(data[in_end:out_end,0])
start +=1

x = np.asanyarray(x)
y = np.asanyarray(y)


My csv file

Error:

data = train.reshape(train.shape(train.shape[0] ,3, train.shape1))

Error image:

Can anyone help me to solve this problem?

Error:

• Would you mind putting the error content, not the image? There are people who can't see the image content and your chance for finding a solution can be diminished. Jul 11 '19 at 9:10
• Please, also provide the line from which you get the error. By the way, the error comes from the last line, namely data = train.reshape(train.shape(train.shape[0] ,3, train.shape[1])) where you've tried to call shape as a method while it is a tuple and you may want to use indexing operator, [index] instead of calling shape as a method. Jul 11 '19 at 9:17
• @Vaalizaadeh Thank you for the fast reply. I understood what you are saying and here I editted my question and here what I am trying to do is x values are my inputs and y value is my output (temperature) y (t+1) . For that I wrote the code. I hope now you can understand my question.
– bala
Jul 11 '19 at 9:34
• @Vaalizaadeh I used the index operator also
– bala
Jul 11 '19 at 9:36
• @Vaalizaadeh I tried it and gave ma an error. Then I tried your earlier methods and also the code that is providing by my friend and I tried again and again. Then I found the correct code for my code. Thank you for helping me to solve this problem. Here I upoad the code below.
– bala
Jul 11 '19 at 15:25

The problem is that train.shape is simply a tuple. So train.shape(arguments) doesn't make sense because train.shape is not callable (hence the error). Try to just replace that line by

data = train.reshape((train.shape[0], 3, train.shape[1]))

• Thank you for the fast reply. I applied your code and it gave me this error " cannot reshape array of size 402 into shape (134,3,3)" here I paste the image of the error.
– bala
Jul 11 '19 at 14:20
• @bala I do not know the dimensions of your array train, and I don’t know to what you want to rescale them. I thought that your array train has the shape shape[0]xshape[1]x3, but that is not the case. You have to think of the compatible shape that you want (I can‘t do that for you because I don‘t know enough about the shape of train). Jul 11 '19 at 14:25
• Ya I got it. Thank you for the reply.
– bala
Jul 11 '19 at 14:27
• @bala You‘re welcome! I‘m glad to have helped. Jul 11 '19 at 14:28
• By using your code and trying another method I found the correct code which is running . Noe my full code is working. I upload my code below. Once again thank you for helping me.
– bala
Jul 11 '19 at 15:20

After Trying all the codes by providing my friends , I found the correct code for my code. Here I upload the code . Thank you for helping me to solve my code.

data = train.reshape((train.shape[0], 1, train.shape[1]))