Converting pandas series object to int in pandas I started my machine learning journey by deciding to explore recommender systems so that I can apply it in some of the projects for my company. Now, I am using Pandas for data analysis. The data set is the imdv movies data set. Here, I am trying to convert a pandas series object to int but it converts the series to float64.

Here is the screenshot:



'clean_ids' is the method that I am using to do this and you can see that 'id' changes to float64. Please help me with this.
Your code is correct. The problem is that you have NaN values in your id column and python interprets NaN as float. In your code any decimal values it encounters will be converted to integer but represented as $x.0$ due to presence on NaN values. See here for more.

As for a solution to your problem you can either drop the NaN values or use IntegerArray from pandas. It is currently experimental but suits yor problem.