David FIM
David FIM

Reputation: 57

Replacing dataframe value with array

I have a time series dataframe that i want to predict with LSTM but i cant replace the train and test value with the scaled value.

This is the dataframe

train dataframe

and this is the scaled data

scaled data

How can i put the scaled value replacing the value in train dataframe ?Since the index is a date and i cant do loop to replacing the data. and i cant replace data in dataframe either.

Thanks in advance

Upvotes: 0

Views: 53

Answers (2)

Pablo C
Pablo C

Reputation: 4771

You can use pandas.DataFrame.replace:

ts_train.replace(ts_train.values, train_data_scaled)

Upvotes: 2

zglin
zglin

Reputation: 2919

You can use a couple of methods, if you want to reassign the data you can create a new dataframe and set the indicies to ts_train_scaled with a command like

pd.Dataframe(data=ts_train_scaled, index=ts_train.index)

If you truly need to replace the value in ts_train, you can use the DataFrame replace command which allows you to replace the value dynamically

Upvotes: 1

Related Questions