Example:
Source DataFrame:
In [109]: df Out[109]: Game Genre PvP Rating_Hype 0 4Story MMORPG Yes 7.32 1 8BitMMO MMORPG Yes Req.Votes 2 9Dragons MMORPG Yes 7.38 3 A Tale in the Desert MMORPG Yes 7.43 4 A3 MMORPG Yes 6.50
Decision:
In [110]: df.Rating_Hype = pd.to_numeric(df.Rating_Hype, errors='coerse') In [111]: df Out[111]: Game Genre PvP Rating_Hype 0 4Story MMORPG Yes 7.32 1 8BitMMO MMORPG Yes NaN 2 9Dragons MMORPG Yes 7.38 3 A Tale in the Desert MMORPG Yes 7.43 4 A3 MMORPG Yes 6.50
We get rid of the lines in which it was not possible to convert the rating into a number:
In [112]: df = df[df.Rating_Hype.notnull()] In [113]: df Out[113]: Game Genre PvP Rating_Hype 0 4Story MMORPG Yes 7.32 2 9Dragons MMORPG Yes 7.38 3 A Tale in the Desert MMORPG Yes 7.43 4 A3 MMORPG Yes 6.50
All the same one team:
In [117]: df = df.assign(Rating_Hype=pd.to_numeric(df.Rating_Hype, errors='coerse')) \ .query("Rating_Hype == Rating_Hype") In [118]: df Out[118]: Game Genre PvP Rating_Hype 0 4Story MMORPG Yes 7.32 2 9Dragons MMORPG Yes 7.38 3 A Tale in the Desert MMORPG Yes 7.43 4 A3 MMORPG Yes 6.50 In [119]: df.dtypes Out[119]: Game object Genre object PvP object Rating_Hype float64 # <----------------- dtype: object