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

Method _align_frame

pandas/core/generic.py:9861–9904  ·  view source on GitHub ↗
(
        self,
        other: DataFrame,
        join: AlignJoin = "outer",
        axis: Axis | None = None,
        level=None,
        fill_value=None,
    )

Source from the content-addressed store, hash-verified

9859
9860 @final
9861 def _align_frame(
9862 self,
9863 other: DataFrame,
9864 join: AlignJoin = "outer",
9865 axis: Axis | None = None,
9866 level=None,
9867 fill_value=None,
9868 ) -> tuple[Self, DataFrame, Index | None]:
9869 # defaults
9870 join_index, join_columns = None, None
9871 ilidx, iridx = None, None
9872 clidx, cridx = None, None
9873
9874 is_series = isinstance(self, ABCSeries)
9875
9876 if (axis is None or axis == 0) and not self.index.equals(other.index):
9877 join_index, ilidx, iridx = self.index.join(
9878 other.index, how=join, level=level, return_indexers=True
9879 )
9880
9881 if (
9882 (axis is None or axis == 1)
9883 and not is_series
9884 and not self.columns.equals(other.columns)
9885 ):
9886 join_columns, clidx, cridx = self.columns.join(
9887 other.columns, how=join, level=level, return_indexers=True
9888 )
9889
9890 if is_series:
9891 reindexers = {0: [join_index, ilidx]}
9892 else:
9893 reindexers = {0: [join_index, ilidx], 1: [join_columns, clidx]}
9894
9895 left = self._reindex_with_indexers(
9896 reindexers, fill_value=fill_value, allow_dups=True
9897 )
9898 # other must be always DataFrame
9899 right = other._reindex_with_indexers(
9900 {0: [join_index, iridx], 1: [join_columns, cridx]},
9901 fill_value=fill_value,
9902 allow_dups=True,
9903 )
9904 return left, right, join_index
9905
9906 @final
9907 def _align_series(

Callers 2

alignMethod · 0.95

Calls 3

equalsMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected