MCPcopy
hub / github.com/pandas-dev/pandas / append

Method append

pandas/core/indexes/base.py:5464–5506  ·  view source on GitHub ↗

Append a collection of Index options together. Parameters ---------- other : Index or list/tuple of indices Single Index or a collection of indices, which can be either a list or a tuple. Returns ------- Index

(self, other: Index | Sequence[Index])

Source from the content-addressed store, hash-verified

5462 return False
5463
5464 def append(self, other: Index | Sequence[Index]) -> Index:
5465 """
5466 Append a collection of Index options together.
5467
5468 Parameters
5469 ----------
5470 other : Index or list/tuple of indices
5471 Single Index or a collection of indices, which can be either a list or a
5472 tuple.
5473
5474 Returns
5475 -------
5476 Index
5477 Returns a new Index object resulting from appending the provided other
5478 indices to the original Index.
5479
5480 See Also
5481 --------
5482 Index.insert : Make new Index inserting new item at location.
5483
5484 Examples
5485 --------
5486 >>> idx = pd.Index([1, 2, 3])
5487 >>> idx.append(pd.Index([4]))
5488 Index([1, 2, 3, 4], dtype='int64')
5489 """
5490 to_concat = [self]
5491
5492 if isinstance(other, (list, tuple)):
5493 to_concat += list(other)
5494 else:
5495 # error: Argument 1 to "append" of "list" has incompatible type
5496 # "Union[Index, Sequence[Index]]"; expected "Index"
5497 to_concat.append(other) # type: ignore[arg-type]
5498
5499 for obj in to_concat:
5500 if not isinstance(obj, Index):
5501 raise TypeError("all inputs must be Index")
5502
5503 names = {obj.name for obj in to_concat}
5504 name = None if len(names) > 1 else self.name
5505
5506 return self._concat(to_concat, name)
5507
5508 def _concat(self, to_concat: list[Index], name: Hashable) -> Index:
5509 """

Callers 15

_unionMethod · 0.95
_get_fill_indexerMethod · 0.95
test_append_indexFunction · 0.95
test_append_multipleMethod · 0.95
load_newobjMethod · 0.45
case_whenMethod · 0.45
_gotitemMethod · 0.45
union_with_duplicatesFunction · 0.45
_decons_group_indexFunction · 0.45

Calls 1

_concatMethod · 0.95

Tested by 5

test_append_indexFunction · 0.76
test_append_multipleMethod · 0.76