Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The Kernel crashes when I use np.float64

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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().

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading