Questions regarding Python code.

Asked 2 years ago, Updated 2 years ago, 74 views

Hello, I am not sure why there is an error when there is a part that is blocked while studying the LSTM related code.

The code is as follows.

I marked **, but I don't know why there is an error.

The code is a reproduction of what comes out of the YouTube video, but I can't proceed because there is an error in this part...

Thank you for reading!

main_df = pd.DataFrame()

ratios = ["BTC-USD", "LTC-USD", "BCH-USD", "ETH-USD"] for ratio in ratios: print(ratio) dataset = f'training_datas/{ratio}.csv'
df = pd.read_csv(dataset, names=['time', 'low', 'high', 'open', 'close', 'volume'])

df.rename(columns={"close": f"{ratio}_close", "volume": f"{ratio}_volume"}, inplace=True)

df.set_index("time", inplace=True)  
df = df[[f"{ratio}_close", f"{ratio}_volume"]] 

if len(main_df)==0:  
    main_df = df  
else:  
    main_df = main_df.join(df)

main_df.fillna(method="ffill", inplace=True) main_df.dropna(inplace=True) print(main_df.head())

Error contents.

File "", line 6

dataset = f'training_datas/{ratio}.csv'
                               ^

SyntaxError: invalid syntax

Thank you for reading.

brace

2022-09-22 19:31

1 Answers

I think the Python version you are using is Python 2. The code given is a code that can be written in Python3, so an error seems to occur.

Please run the code with Python3 and let me know again if the same error occurs.


2022-09-22 19:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.