elena1234

Data Transformation in Python

Jul 21st, 2022 (edited)
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. # Performing logarithmic transformation on the feature
  2. cp['price_log']=np.log(cp['price'])
  3.  
  4. # Reciprocal Transformation – This will inverse values of Price i.e1/Price
  5. cp['price_reciprocal']=np.reciprocal(cp.price)
  6. normality(cp,'price_reciprocal')
  7.  
  8. # Square Root Transformation
  9. cp['price_sqroot']=np.sqrt(cp.price)
  10. normality(cp,'price_sqroot')
  11.  
  12. # Exponential Transformation: The exponential value of the Price variable will be taken.
  13. cp['price_exponential']=np.exp(cp.price)
  14. normality(cp,'price_exponential')
  15.  
  16. # Box-Cox Transformation
  17. cp['price_Boxcox'],parameters=stats.boxcox(cp['price'])
Add Comment
Please, Sign In to add comment