Skip to content
Advertisement

How to convert dtype from ‘0’ to ‘int64’?

I started working with a dataset, which is a collection of murder reports.There is a column “Perpetrator Age” in which there are simple integers. But when I looked at his type, it turned out that he was dtype('O').

In order to work with this column further, I want to change its type to dtype('int64'). I tried to do it like this:

JavaScript

and got this error:

JavaScript

I saw advice for the “object” type, which must first be converted to a string, and then to “int”. Tried it, it didn’t work either, same error appeared. Please tell me how I can fix this?

Advertisement

Answer

As mentioned in the comments, the first row of your df is apparently an empty space (' '). You can either remove it, replace it with something else, or skip it:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement