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

Function _get_result

pandas/core/reshape/concat.py:553–664  ·  view source on GitHub ↗
(
    objs: list[Series | DataFrame],
    is_series: bool,
    bm_axis: AxisInt,
    ignore_index: bool,
    intersect: bool,
    sort: bool | lib.NoDefault,
    keys: Iterable[Hashable] | None,
    levels,
    verify_integrity: bool,
    names: list[HashableT] | None,
    axis: AxisInt,
)

Source from the content-addressed store, hash-verified

551
552
553def _get_result(
554 objs: list[Series | DataFrame],
555 is_series: bool,
556 bm_axis: AxisInt,
557 ignore_index: bool,
558 intersect: bool,
559 sort: bool | lib.NoDefault,
560 keys: Iterable[Hashable] | None,
561 levels,
562 verify_integrity: bool,
563 names: list[HashableT] | None,
564 axis: AxisInt,
565):
566 cons: Callable[..., DataFrame | Series]
567 sample: DataFrame | Series
568
569 # series only
570 if is_series:
571 sample = cast("Series", objs[0])
572
573 # stack blocks
574 if bm_axis == 0:
575 name = com.consensus_name_attr(objs)
576 cons = sample._constructor
577
578 arrs = [ser._values for ser in objs]
579
580 res = concat_compat(arrs, axis=0)
581
582 if ignore_index:
583 new_index: Index = default_index(len(res))
584 else:
585 new_index = _get_concat_axis_series(
586 objs,
587 ignore_index,
588 bm_axis,
589 keys,
590 levels,
591 verify_integrity,
592 names,
593 )
594
595 mgr = type(sample._mgr).from_array(res, index=new_index)
596
597 result = sample._constructor_from_mgr(mgr, axes=mgr.axes)
598 result._name = name
599 return result.__finalize__(
600 types.SimpleNamespace(input_objs=objs, objs=objs), method="concat"
601 )
602
603 # combine as columns in a frame
604 else:
605 data = dict(enumerate(objs))
606
607 # GH28330 Preserves subclassed objects through concat
608 cons = sample._constructor_expanddim
609
610 index = get_objs_combined_axis(

Callers 1

concatFunction · 0.85

Calls 13

concat_compatFunction · 0.90
default_indexFunction · 0.90
get_objs_combined_axisFunction · 0.90
concatenate_managersFunction · 0.90
_get_concat_axis_seriesFunction · 0.85
new_axesFunction · 0.85
from_arrayMethod · 0.80
__finalize__Method · 0.80
_constructor_from_mgrMethod · 0.45
equalsMethod · 0.45
get_indexerMethod · 0.45

Tested by

no test coverage detected