Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

divide a column value in pandas dataframe

df = pd.DataFrame({'A':[61.75, 10.25], 'B':[0.62, 0.45]})
print (df)
       A     B
0  61.75  0.62
1  10.25  0.45

df['A'] = df['A'].div(100).round(2)
#same as
#df['A'] = (df['A'] / 100).round(2)
print (df)
      A     B
0  0.62  0.62
1  0.10  0.45
Comment

PREVIOUS NEXT
Code Example
Python :: find common values in different dataframes pandas 
Python :: python append a file and read 
Python :: django updated_at field 
Python :: anagram program in python 
Python :: remove specific word from string using python 
Python :: how to update python 
Python :: how to change username of a bot using discord.py 
Python :: image rotate in python 
Python :: shutil move file 
Python :: manipulate ip address in python 
Python :: merge two Python dictionaries in a single expression 
Python :: np to tuple 
Python :: xa python 
Python :: regex findall 
Python :: template string python 
Python :: python file parent 
Python :: python how to import library absoluth path 
Python :: python set and dictionary comprehensions 
Python :: how to make a countdown in pygame 
Python :: curl python 
Python :: count occurrences of a character in a string python 
Python :: compress tarfile python 
Python :: python swap two values in list 
Python :: python get average of list 
Python :: filter pandas dataframe 
Python :: change colors markdown pyhton 
Python :: json python 
Python :: python http.server 
Python :: django drop all tables 
Python :: append path to sys jupyter notebook 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =