60👍
What the error is telling, is that you can’t convert an entire list into an integer. You could get an index from the list and convert that into an integer:
x = ["0", "1", "2"]
y = int(x[0]) #accessing the zeroth element
If you’re trying to convert a whole list into an integer, you are going to have to convert the list into a string first:
x = ["0", "1", "2"]
y = ''.join(x) # converting list into string
z = int(y)
If your list elements are not strings, you’ll have to convert them to strings before using str.join
:
x = [0, 1, 2]
y = ''.join(map(str, x))
z = int(y)
Also, as stated above, make sure that you’re not returning a nested list.
1👍
int() argument must be a string, a bytes-like object, or a number, not ‘NoneType’
According to the error, you can’t convert strings type data into integers, So if a column contains null values as NaN then the type of NaN is float, so you can convert that into float.
check type of NaN -> type(np.NaN) ==> float
- [Django]-Pypi see older versions of package
- [Django]-Cross domain at axios
- [Django]-Django: using <select multiple> and POST
0👍
integer_list = [int(item) for line in list for item in line]
In this way you can convert string to integer in a list
- [Django]-Django-reversion and related model
- [Django]-How to know current name of the database in Django?
- [Django]-How do I stop getting ImportError: Could not import settings 'mofin.settings' when using django with wsgi?