Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

dataframe subtract value from previous row

In [138]: df.Close.pct_change() * 100
Out[138]:
0         NaN
1    0.469484
2    0.467290
3   -0.930233
4    0.469484
5    0.467290
6    0.000000
7   -3.255814
8   -3.365385
9   -0.497512
Name: Close, dtype: float64

In [139]: df.Close.diff()
Out[139]:
0      NaN
1    0.125
2    0.125
3   -0.250
4    0.125
5    0.125
6    0.000
7   -0.875
8   -0.875
9   -0.125
Name: Close, dtype: float64
Comment

PREVIOUS NEXT
Code Example
Python :: spacy access vocabulary 
Python :: python list files in folder with wildcard 
Python :: create table pyspark sql 
Python :: double quotes in python dictionary 
Python :: gaussian filter 
Python :: write in entry() in tkinter 
Python :: transpose matrix in python without numpy 
Python :: react-native-dropdown-picker 
Python :: reverse function python 
Python :: how to make a button in python 
Python :: from one hot encoding to integer python 
Python :: r named chr to dataframe 
Python :: os.move file 
Python :: convert 2d aray into 1d using python 
Python :: A Python Class Constructor 
Python :: install apriori package python 
Python :: python convert list of lists to array 
Python :: count number items in list python 
Python :: Example Layout using grid() in tkinter 
Python :: perform_update serializer django 
Python :: replace nan using fillna 
Python :: get current url with parameters url django 
Python :: remote python running line by line visual code 
Python :: flask bootstrap 
Python :: spyder new instance 
Python :: uses specific version python venv 
Python :: pandas load feather 
Python :: write image out opencv 
Python :: WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. buildozer 
Python :: confusion matrix with labels sklearn 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =