Comments

Data Formating in Python

 



All value in specific column must be in the same format, another thing we may want to convert entire column to specific format, and we can manipulate it by divided or convert to specific format, for example how to convert miles per gallon to l/100km we just divided by 235.215 as follow: 

  • To convert entire column:                                                
     df["column_name"] = 235/df["column_name"]
  

  •    To rename the title of column:  

     df.rename(columns={"coumns_name1":"column_name2"}, inplace=True)

  • To know the data type :                          
    df["column_name"].tail(5)
  • Identify data type                                     
    df["column_name"].dtypes()
  • convert data type of column             
    df["column_name"] = df["column_name"].astype("int")
Share on Google Plus

About Inas AL-Kamachy

    Blogger Comment
    Facebook Comment

0 Comments:

Post a Comment