Advertisement
elena1234

change the price in various currency in Python

Dec 13th, 2022 (edited)
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | Source Code | 0 0
  1. d = {'EUR': 1.95, 'USD': 1.90, 'лв.': 1}
  2. s1 = df_auto['Price'].replace(d, regex=True)
  3. s2 = df_auto['Price'].str.extract('(\d+\ \d*)',expand = False)
  4. s2 = s2.str.replace(' ','') # 23 444 --> 23444
  5. s2 = s2.astype(float)
  6. df_auto['Price BGN'] = s1 * s2
  7.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement