Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas get row if difference previous

>>> df = pd.DataFrame({'a': [1, 2, 3],
...                    'b': [1, 1, 2],
...                    'c': [1, 4, 9]})

>>> df
   a  b   c
0  1  1   1
1  2  1   4
2  3  2   9

>>> df.diff()

     a    b     c
0  NaN  NaN   NaN
1  1.0  0.0   3.0
2  1.0  1.0   5.0
Source by pandas.pydata.org #
 
PREVIOUS NEXT
Tagged: #pandas #row #difference #previous
ADD COMMENT
Topic
Name
8+3 =