The Kernel crashes when I use np.float64

Question:

When I define the following code, and try to "apply" it to a dataframe, it gives me the above error, and when I change dtype from float64 to float32, I don’t get any errors. What might be the issue?

def round(x):
    if x.dtype == np.float64:
        return round(x)
    else:
        return x

I am just following along a bootcamp, and this happened. I am using VS Code by the way

Asked By: Who_amI

||

Answers:

You are defining the function round and then call it within itself (recursion) without any termination criteria.

A solution might be to name your function my_round or something different from the built-in function round. Or, as @tevemadar pointed out in the comment, use np.round().

Answered By: Jan
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.