I am not using any float object in my code ,yet it is showing 'float' object not iterable as warning. The dataset is Titanic Dataset from Kaggle.
I have tried changing the variable name in case I might have used it somewhere else but to no avail. (ie,from x to the current variable y). I have imported the numpy library too. Also I tried using the snippet of code out of the while loop while giving some value of i ( say 1) and it worked perfectly fine.
i= 0
while i <= 890:
if (dataset.loc[i , 'Cabin'] != np.NaN):
y = list(dataset.loc[i , 'Cabin'])
dataset.loc[i , 'Cabin'] = y[0]
i= i+1
The cabin column of the dataset has alphanumeric values like 'C123'. I just wanted the 'C' or the first letter of the alphanumeric value.Which is why I changed it into a list and took the first array element. But I get..
TypeError Traceback (most recent call
last)
<ipython-input-70-3eeda9c4954a> in <module>
2 while i <= 890:
3 if (dataset.loc[i , 'Cabin'] != np.NaN):
----> 4 y = list(dataset.loc[i , 'Cabin'])
5 dataset.loc[i , 'Cabin'] = y[0]
6 i= i+1
TypeError: 'float' object is not iterable