Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

indexerror: invalid index to scalar variable.

# You might be trying to index a scalar (non-iterable) value:

[y[1] for y in y_test]
#  ^ this is the problem

# When you call [y for y in test] you are iterating over the values already, so you get a single value in y.
# Your code is the same as trying to do the following:

y_test = [1, 2, 3]
y = y_test[0] # y = 1
print(y[0]) # this line will fail

# instead you could use a for loop:

for y in y_test:
    results.append(..., y)
Comment

PREVIOUS NEXT
Code Example
Python :: python if not null 
Python :: flask migrate multiple heads 
Python :: how stract avery .jpg string in a website python 
Python :: vigenere cipher with all printable characters python 
Python :: éliminer le background image python 
Python :: item[0]: (i + 1) * 2 for i, item in (sort_loc) 
Python :: python newline 
Python :: How to filter words that contain atleast 2 vowels from a series 
Python :: how to convert a string to a list python 
Python :: inherit functions from other classes 
Python :: telegram.ext package python 
Python :: instalar sympy en thonny 
Python :: # read table data from PDF into dataframe and save it as csv or json 
Python :: change gles3 to gles2 
Python :: how to plot a single cluster 
Python :: pyspark parquet to dataframe 
Python :: pytesseract restrict char 
Python :: import in python 
Python :: python build a string using reduce and concatenate 
Python :: how to print list without newline 
Python :: how to check system has internet using python 
Python :: Forbidden (CSRF token missing or incorrect.): /extension/stripe-pay/ WARNING 2021-06-01 13:45:22,532 log 408 140165573588736 Forbidden (CSRF token missing or incorrect.): /extension/stripe-pay/ 
Python :: how to remove axis in matplotlib 
Python :: Using strip() method to remove the newline character from a string 
Python :: join on index python 
Python :: binary search iterative 
Python :: python should i use getters and setters 
Python :: validate string using six library python 
Python :: retrieve content inside the meta tag python 
Python :: how to display python output on html page django 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =