@@ -229,30 +229,155 @@ def unique(self) -> Self:
229229 return self ._from_backing_data (new_data )
230230
231231 @classmethod
232- @doc (ExtensionArray ._concat_same_type )
233232 def _concat_same_type (
234233 cls ,
235234 to_concat : Sequence [Self ],
236235 axis : AxisInt = 0 ,
237236 ) -> Self :
237+ """
238+ Concatenate multiple array of this dtype.
239+
240+ Parameters
241+ ----------
242+ to_concat : sequence of this type
243+ An array of the same dtype to concatenate.
244+
245+ Returns
246+ -------
247+ ExtensionArray
248+
249+ See Also
250+ --------
251+ api.extensions.ExtensionArray._explode : Transform each element of
252+ list-like to a row.
253+ api.extensions.ExtensionArray._formatter : Formatting function for
254+ scalar values.
255+ api.extensions.ExtensionArray._from_factorized : Reconstruct an
256+ ExtensionArray after factorization.
257+
258+ Examples
259+ --------
260+ >>> arr1 = pd.array([1, 2, 3])
261+ >>> arr2 = pd.array([4, 5, 6])
262+ >>> pd.arrays.IntegerArray._concat_same_type([arr1, arr2])
263+ <IntegerArray>
264+ [1, 2, 3, 4, 5, 6]
265+ Length: 6, dtype: Int64
266+ """
238267 if not lib .dtypes_all_equal ([x .dtype for x in to_concat ]):
239268 dtypes = {str (x .dtype ) for x in to_concat }
240269 raise ValueError ("to_concat must have the same dtype" , dtypes )
241270
242271 return super ()._concat_same_type (to_concat , axis = axis )
243272
244- @doc (ExtensionArray .searchsorted )
245273 def searchsorted (
246274 self ,
247275 value : NumpyValueArrayLike | ExtensionArray ,
248276 side : Literal ["left" , "right" ] = "left" ,
249277 sorter : NumpySorter | None = None ,
250278 ) -> npt .NDArray [np .intp ] | np .intp :
251- npvalue = self ._validate_setitem_value (value )
252- return self ._ndarray .searchsorted (npvalue , side = side , sorter = sorter )
279+ """
280+ Find indices where elements should be inserted to maintain order.
281+
282+ Find the indices into a sorted array `self` (a) such that, if the
283+ corresponding elements in `value` were inserted before the indices,
284+ the order of `self` would be preserved.
285+
286+ Assuming that `self` is sorted:
287+
288+ ====== ================================
289+ `side` returned index `i` satisfies
290+ ====== ================================
291+ left ``self[i-1] < value <= self[i]``
292+ right ``self[i-1] <= value < self[i]``
293+ ====== ================================
294+
295+ Parameters
296+ ----------
297+ value : array-like, list or scalar
298+ Value(s) to insert into `self`.
299+ side : {'left', 'right'}, optional
300+ If 'left', the index of the first suitable location found is given.
301+ If 'right', return the last such index. If there is no suitable
302+ index, return either 0 or N (where N is the length of `self`).
303+ sorter : 1-D array-like, optional
304+ Optional array of integer indices that sort array a into ascending
305+ order. They are typically the result of argsort.
306+
307+ Returns
308+ -------
309+ array of ints or int
310+ If value is array-like, array of insertion points.
311+ If value is scalar, a single integer.
312+
313+ See Also
314+ --------
315+ numpy.searchsorted : Similar method from NumPy.
316+
317+ Examples
318+ --------
319+ >>> arr = pd.array([1, 2, 3, 5])
320+ >>> arr.searchsorted([4])
321+ array([3])
322+ """
323+ # Note: the base tests provided by pandas only test the basics.
324+ # We do not test
325+ # 1. Values outside the range of the `data_for_sorting` fixture
326+ # 2. Values between the values in the `data_for_sorting` fixture
327+ # 3. Missing values.
328+ arr = self .astype (object )
329+ if isinstance (value , ExtensionArray ):
330+ value = value .astype (object )
331+ return arr .searchsorted (value , side = side , sorter = sorter )
253332
254- @doc (ExtensionArray .shift )
255333 def shift (self , periods : int = 1 , fill_value = None ) -> Self :
334+ """
335+ Shift values by desired number.
336+
337+ Newly introduced missing values are filled with
338+ ``self.dtype.na_value``.
339+
340+ Parameters
341+ ----------
342+ periods : int, default 1
343+ The number of periods to shift. Negative values are allowed
344+ for shifting backwards.
345+
346+ fill_value : object, optional
347+ The scalar value to use for newly introduced missing values.
348+ The default is ``self.dtype.na_value``.
349+
350+ Returns
351+ -------
352+ ExtensionArray
353+ Shifted.
354+
355+ See Also
356+ --------
357+ api.extensions.ExtensionArray.transpose : Return a transposed view on
358+ this array.
359+ api.extensions.ExtensionArray.factorize : Encode the extension array as an
360+ enumerated type.
361+
362+ Notes
363+ -----
364+ If ``self`` is empty or ``periods`` is 0, a copy of ``self`` is
365+ returned.
366+
367+ If ``periods > len(self)``, then an array of size
368+ len(self) is returned, with all values filled with
369+ ``self.dtype.na_value``.
370+
371+ For 2-dimensional ExtensionArrays, we are always shifting along axis=0.
372+
373+ Examples
374+ --------
375+ >>> arr = pd.array([1, 2, 3])
376+ >>> arr.shift(2)
377+ <IntegerArray>
378+ [<NA>, <NA>, 1]
379+ Length: 3, dtype: Int64
380+ """
256381 # NB: shift is always along axis=0
257382 axis = 0
258383 fill_value = self ._validate_scalar (fill_value )
@@ -338,8 +463,44 @@ def _pad_or_backfill(
338463 new_values = self
339464 return new_values
340465
341- @doc (ExtensionArray .fillna )
342466 def fillna (self , value , limit : int | None = None , copy : bool = True ) -> Self :
467+ """
468+ Fill NA/NaN values using the specified method.
469+
470+ Parameters
471+ ----------
472+ value : scalar, array-like
473+ If a scalar value is passed it is used to fill all missing values.
474+ Alternatively, an array-like "value" can be given. It's expected
475+ that the array-like have the same length as 'self'.
476+ limit : int, default None
477+ The maximum number of entries where NA values will be filled.
478+ copy : bool, default True
479+ Whether to make a copy of the data before filling. If False, then
480+ the original should be modified and no new memory should be allocated.
481+ For ExtensionArray subclasses that cannot do this, it is at the
482+ author's discretion whether to ignore "copy=False" or to raise.
483+
484+ Returns
485+ -------
486+ ExtensionArray
487+ With NA/NaN filled.
488+
489+ See Also
490+ --------
491+ api.extensions.ExtensionArray.dropna : Return ExtensionArray without
492+ NA values.
493+ api.extensions.ExtensionArray.isna : A 1-D array indicating if
494+ each value is missing.
495+
496+ Examples
497+ --------
498+ >>> arr = pd.array([np.nan, np.nan, 2, 3, np.nan, np.nan])
499+ >>> arr.fillna(0)
500+ <IntegerArray>
501+ [0, 0, 2, 3, 0, 0]
502+ Length: 6, dtype: Int64
503+ """
343504 mask = self .isna ()
344505 if limit is not None and limit < len (self ):
345506 # mypy doesn't like that mask can be an EA which need not have `cumsum`
0 commit comments