How To remove the -ve signs from total_amount, qty, and rate column in python

Viewed 51
transaction_id  cust_id tran_date   prod_subcat_code    prod_cat_code   Qty Rate    Tax total_amt   Store_type
0   80712190438 270351  28-02-2014  1                          1          -5    -772    405.300 -4265.300   e-Shop
1   29258453508 270384  27-02-2014  5                          3          -5    -1497   785.925 -8270.925   e-Shop
2   51750724947 273420  24-02-2014  6                          5          -2    -791    166.110 -1748.110   TeleShop
3   93274880719 271509  24-02-2014  11                         6           -3   -1363   429.345 -4518.345   e-Shop
4   51750724947 273420  23-02-2014  6                          5           -2   -791    166.110 -1748.110   TeleShop

How To remove the -ve signs from each column

1 Answers

Does this solve your question?

df[['Qty', 'Rate', 'Tax', 'total_amt']].apply(abs)

Here I'm using the built-in abs(absolute value of the number) to convert the negative numbers into positive ones.

Hope so this is useful to you and solves your question!
Happy Coding!

Related