When processing data with Pandas, I think that there are times when batch processing is performed using ʻapply ()`.
What to do when you want to find out what line was the error in the process of ʻapply ()`.
df.Column name.apply(function name)
df['Column name'].apply(function name)
When an error is output with the above code.
Use the generator to resolve which line caused the error.
def generater():
x = 0
while True:
yield x
x += 1
After that, add the following before and within the function definition.
g = generater() #add to
def function_name():
print(g.__next__()) #add to
Recommended Posts