Python Data Analysis - TypeError: 'Int' Object Is Not iTerable

tags: python  data analysis  pandas

This article is mainly to record a small problem I have encountered in the process of knocking the code. After the code is written, I don't pay attention to the small mistakes made. In fact, this problem should not be written (manually shameful expression), why writing What? Because I feel correct when I first started. . . Specially write down to wake yourself.

Question: Cycate the type of element of the DataFrame, then do the wrong time to clean it, the report of the For loop.

I will guess what I have to do if I look at the code below. . . It's so simple ~

a = pd.DataFrame({'one':[1,2,3,4,5],'two':['q','','e','','t'],'three':['','ss','',11,'gg']})
# b = []
for i in len(a):
    print(i)

Then report an error:
 Here INT is an integer variable, so it cannot be iterated. . .
Therefore, the code is changed:

a = pd.DataFrame({'one':[1,2,3,4,5],'two':['q','','e','','t'],'three':['','ss','',11,'gg']})
# b = []
for i in range(len(a)):
    print(i)

OK is OK. . .

Intelligent Recommendation

Python3 TypeError:'int' object is not iterable

I got an error when doing iterative calculation in Python3 TypeError: 'int' object is not iterable   Translated is that the int object is not iterable The wrong code is because of the left T...

Solve TypeError:'int' object is not iterable

Solve TypeError:'int' object is not iterable Problems encountered when playing cnn neural network for the first time Solution: Add a range to the label in the for loop of the code. The effect is as fo...

tensorflow TypeError: “int“ object is not iterable

I don't know what the hell this is, it may be a version problem. Can't play. . . You can just try some of Ali's projects. Recently, people still use 1.3. Can you imagine? ?   For Video Recommenda...

[ ] Python "Typeerror: 'Nonetype' Object Is Not Iterable" Error Analysis

https://blog.csdn.net/dataspark/article/details/9953225 [Analysis] Generally, the function return value is none and is assigned to multiple variables. [Case] Define the following functions When using ...

Keras implements mnist data classification-TypeError:'int' object is not iterable

The reason is that the input_shape input format is wrong There should be a comma Complete code:...

More Recommendation

Python (string to tuple perfect solution) TypeError,'int' object is not iterable solution

When I was working today, I encountered such a problem: the string was transferred to tuple. He was scattered, which caused me to write Excel in the following situation that I did not want, and then t...

Solve Python error TypeError: Cannot Unpack Non-iTerable Int Object

Problem Description Use the following code to variablesa, bAssign the same value to report an error: Cause Analysis It should not be useda, b = 1The way is assigned, then the assignment method is chan...

Python error Answers - TypeError: Cannot Unpack Non-Iterable Int Object

TypeError: cannot unpack non-iterable int object An error is as follows Cause Analysis An error is as follows Cause Analysis The function returns a number of inconsistencies, check the number of retur...

For i in number_feature: TypeError: 'int' object is not iterable

Code The result appears :for i in number_feature: TypeError: 'int' object is not iterable error The reason for the error is because in Python, integer (int) data cannot be used directly for iteration,...

usecols = list(usecols) TypeError: 'int' object is not iterable

usecols : int or sequence, optional Which columns to read, with 0 being the first. For example, usecols = (1,4,5) will extract the 2nd, 5th and 6th columns. The default, None, results in all columns b...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top