@@ -1426,10 +1426,12 @@ def interpolate(
1426
1426
nb = self .make_block_same_class (data , refs = refs )
1427
1427
return nb ._maybe_downcast ([nb ], downcast , using_cow )
1428
1428
1429
- def diff (self , n : int , axis : AxisInt = 1 ) -> list [Block ]:
1429
+ @final
1430
+ def diff (self , n : int ) -> list [Block ]:
1430
1431
"""return block for the diff of the values"""
1431
- # only reached with ndim == 2 and axis == 1
1432
- new_values = algos .diff (self .values , n , axis = axis )
1432
+ # only reached with ndim == 2
1433
+ # TODO(EA2D): transpose will be unnecessary with 2D EAs
1434
+ new_values = algos .diff (self .values .T , n , axis = 0 ).T
1433
1435
return [self .make_block (values = new_values )]
1434
1436
1435
1437
def shift (
@@ -2067,12 +2069,6 @@ def slice_block_rows(self, slicer: slice) -> Self:
2067
2069
new_values = self .values [slicer ]
2068
2070
return type (self )(new_values , self ._mgr_locs , ndim = self .ndim , refs = self .refs )
2069
2071
2070
- def diff (self , n : int , axis : AxisInt = 1 ) -> list [Block ]:
2071
- # only reached with ndim == 2 and axis == 1
2072
- # TODO(EA2D): Can share with NDArrayBackedExtensionBlock
2073
- new_values = algos .diff (self .values , n , axis = 0 )
2074
- return [self .make_block (values = new_values )]
2075
-
2076
2072
def shift (
2077
2073
self , periods : int , axis : AxisInt = 0 , fill_value : Any = None
2078
2074
) -> list [Block ]:
@@ -2191,32 +2187,6 @@ def is_view(self) -> bool:
2191
2187
# check the ndarray values of the DatetimeIndex values
2192
2188
return self .values ._ndarray .base is not None
2193
2189
2194
- def diff (self , n : int , axis : AxisInt = 0 ) -> list [Block ]:
2195
- """
2196
- 1st discrete difference.
2197
-
2198
- Parameters
2199
- ----------
2200
- n : int
2201
- Number of periods to diff.
2202
- axis : int, default 0
2203
- Axis to diff upon.
2204
-
2205
- Returns
2206
- -------
2207
- A list with a new Block.
2208
-
2209
- Notes
2210
- -----
2211
- The arguments here are mimicking shift so they are called correctly
2212
- by apply.
2213
- """
2214
- # only reached with ndim == 2 and axis == 1
2215
- values = self .values
2216
-
2217
- new_values = values - values .shift (n , axis = axis )
2218
- return [self .make_block (new_values )]
2219
-
2220
2190
def shift (
2221
2191
self , periods : int , axis : AxisInt = 0 , fill_value : Any = None
2222
2192
) -> list [Block ]:
0 commit comments