简体   繁体   中英

ValueError when assigning value to time series (ts)

I am currently working on a neural network that detects cardiac arrythmia. A convolutional neural network has been implemented as the back end to a Flask web application. I've based my program on this Github repository

However, I have run into this problem in the Anaconda terminal. For some reason, it is not possible to convert the strings in the CSV into the int or float datatype. GitHub states there are no commas in the file, but it seems to load just fine into Excel and Spyder.

Is this problem because of the no comma problem or is it related to the program itself? I've spent all morning trying to fix this to no avail. Any help would be appreciated.

    File "app.py", line 47, in model_predict
    ts = int((str(path)[index1:index2])) ### this is the line causing the error
ValueError: invalid literal for int() with base 10: 'ds\\sample'

Here is the line causing the issue in detail:

def model_predict(uploaded_files, model):
    flag = 1

    for path in uploaded_files:
        index1 = str(path).find('sig-2') + 6
        index2 = -4
        ts = int((str(path)[index1:index2])) ### this is the line causing the error

Your question has hardly anything to do with either neural-network, time-series or conv-neural-network.

The thing is that you are parsing a file name (or whatever) containing 'sig-2' and 6 characters later and 4 characters before the end you expect the string to be convertible to an integer.

But in fact you get 'ds\\\\sample' which is hardly convertible to an int.

I advise you to use a debugger ( PyCharm ) and to check the naming of your files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM