File tree 2 files changed +6
-5
lines changed
2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 24
24
from pandas .core .dtypes .missing import isna
25
25
26
26
from pandas .core import ops
27
- from pandas .core .algorithms import _factorize_array , unique
27
+ from pandas .core .algorithms import _factorize_array , diff , unique
28
28
from pandas .core .missing import backfill_1d , pad_1d
29
29
from pandas .core .sorting import nargsort
30
30
@@ -516,6 +516,9 @@ def argsort(
516
516
result = nargsort (self , kind = kind , ascending = ascending , na_position = "last" )
517
517
return result
518
518
519
+ def diff (self , n_periods ):
520
+ return type (self )._from_sequence (diff (self , n_periods ), dtype = self .dtype )
521
+
519
522
def fillna (self , value = None , method = None , limit = None ):
520
523
"""
521
524
Fill NA/NaN values using the specified method.
Original file line number Diff line number Diff line change @@ -2316,13 +2316,11 @@ def diff(self, periods=1) -> "Series":
2316
2316
5 NaN
2317
2317
dtype: float64
2318
2318
"""
2319
- result = algorithms .diff (com .values_from_object (self ), periods )
2320
2319
if is_extension_array_dtype (self .dtype ) and not is_datetime64tz_dtype (
2321
2320
self .dtype
2322
2321
):
2323
- return self ._constructor (
2324
- result , index = self .index , dtype = self .dtype
2325
- ).__finalize__ (self )
2322
+ return self .values .diff (n_periods = periods )
2323
+ result = algorithms .diff (com .values_from_object (self ), periods )
2326
2324
return self ._constructor (result , index = self .index ).__finalize__ (self )
2327
2325
2328
2326
def autocorr (self , lag = 1 ) -> float :
You can’t perform that action at this time.
0 commit comments