0

I have a dataframe that contain some data.

import pandas as pd
start = time.time()
data_store = pd.read_excel("101010.xlsx")
print(data_store)

A                      B
100                    -200
100                    -99
200                    -150
100                    150
50                     -60
70                     50
80                     -100
25                     15
30                     40
50                     -25

I want to apply Math's Mod function in python pandas dataframe and print that result.

Ex:- |-200| = 200

Please can some body help me how i can apply this function in python pandas dataframe.

Thank you in advance :) :) :)

Amelia
  • 1
  • 2
  • 3
    Do you think absolute values? `df.B.abs()`? Or modulo? What is expected output from sample data? – jezrael Sep 09 '20 at 05:17

1 Answers1

0
  • python: 3.8.5
  • pandas: 1.1.1
  • xlrd: 1.2.0

Reference:

  1. pandas.DataFrame.abs

  2. Absolute value for column in Python

import pandas as pd
data_store = pd.read_excel('101010.xlsx')
data_store.B = data_store.B.abs()  # Absoulte value of Column B
print(data_store)

   A    B
0  100  200
1  100   99
2  200  150
3  100  150
4   50   60
5   70   50
6   80  100
7   25   15
8   30   40
9   50   25

Leo
  • 1
  • 1