Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas replace % with calculated

def FormatPerc(x): # Create the function to be applied
    perc = 0
    x = str(x)
    
    if '%' in x:
        x = x.replace("%","")
        perc = float(x)*0.001
    else:
        x = x.replace("%","")
        perc = float(x)   
    
    return perc
  
# in your pandas script:
investments['WithdrawPercentage'] = investments['WithdrawPercentage'].apply(FormatPerc)
# any values like "xx.x%" will now be formatted as 0.xxx
Comment

PREVIOUS NEXT
Code Example
Python :: test api register user 
Python :: matplotlib draw line between subplots 
Python :: who is agada nathan 
Python :: fastapi authentication 
Python :: python split files into even sets of folders 
Python :: attributeerror: module 
Python :: matmul shorthand numpy 
Python :: mechanize python XE #27 
Python :: deine dict with same values 
Python :: Location of matploitlibrc file 
Python :: <ipython-input-7-474520f490a8 
Python :: &gt; not supported between tuple and int 
Python :: !r in python fstring 
Python :: django email PasswordResetView template path 
Python :: .format() multiple placeholders 
Python :: Convert Letters to Numbers in Python Using list comprehension 
Python :: get weather data from weather underground 
Python :: axis legend get labels and handles 
Python :: pyttsx3 Running a driver event loop 
Python :: how to convert matlab code into python 
Python :: tuple with mixed data types 
Python :: python log max age linux delete old logs 
Python :: python swap two numbers 
Python :: pandas sample weights example 
Python :: how to check weight value in keras neurons 
Python :: Python NumPy atleast_3d Function Example 2 
Python :: python read file with class 
Python :: Python NumPy require Function Example without requirements attribute 
Python :: Python NumPy tile Function Example Working with 1D array 
Python :: Python how to use __truediv__ 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =