Calculate the inertia tensor and transforms along
        rotation axes.

        This function calculates the inertia tensor and returns
        a 4-tuple.

        The unit is ``amu * length-unit-of-xyz-file**2``

        Args:
            None

        Returns:
            dict: The returned dictionary has four possible keys:

            ``transformed_Cartesian``:
            A :class:`~chemcoord.Cartesian`
            that is transformed to the basis spanned by
            the eigenvectors of the inertia tensor. The x-axis
            is the axis with the lowest inertia moment, the
            z-axis the one with the highest. Contains also a
            column for the mass

            ``diag_inertia_tensor``:
            A vector containing the ascendingly sorted inertia moments after
            diagonalization.

            ``inertia_tensor``:
            The inertia tensor in the old basis.

            ``eigenvectors``:
            The eigenvectors of the inertia tensor in the old basis.
            Since the inertia_tensor is hermitian, they are orthogonal and
            are returned as an orthonormal righthanded basis.
            The i-th eigenvector corresponds to the i-th eigenvalue in
            ``diag_inertia_tensor``.

def get_inertia(self):
        """Calculate the inertia tensor and transforms along
        rotation axes.

        This function calculates the inertia tensor and returns
        a 4-tuple.

        The unit is ``amu * length-unit-of-xyz-file**2``

        Args:
            None

        Returns:
            dict: The returned dictionary has four possible keys:

            ``transformed_Cartesian``:
            A :class:`~chemcoord.Cartesian`
            that is transformed to the basis spanned by
            the eigenvectors of the inertia tensor. The x-axis
            is the axis with the lowest inertia moment, the
            z-axis the one with the highest. Contains also a
            column for the mass

            ``diag_inertia_tensor``:
            A vector containing the ascendingly sorted inertia moments after
            diagonalization.

            ``inertia_tensor``:
            The inertia tensor in the old basis.

            ``eigenvectors``:
            The eigenvectors of the inertia tensor in the old basis.
            Since the inertia_tensor is hermitian, they are orthogonal and
            are returned as an orthonormal righthanded basis.
            The i-th eigenvector corresponds to the i-th eigenvalue in
            ``diag_inertia_tensor``.
        """
        def calculate_inertia_tensor(molecule):
            masses = molecule.loc[:, 'mass'].values
            pos = molecule.loc[:, ['x', 'y', 'z']].values
            inertia = np.sum(
                masses[:, None, None]
                * ((pos**2).sum(axis=1)[:, None, None]
                   * np.identity(3)[None, :, :]
                   - pos[:, :, None] * pos[:, None, :]),
                axis=0)
            diag_inertia, eig_v = np.linalg.eig(inertia)
            sorted_index = np.argsort(diag_inertia)
            diag_inertia = diag_inertia[sorted_index]
            eig_v = eig_v[:, sorted_index]
            return inertia, eig_v, diag_inertia

        molecule = self.add_data('mass')
        molecule = molecule - molecule.get_barycenter()
        inertia, eig_v, diag_inertia = calculate_inertia_tensor(molecule)
        eig_v = xyz_functions.orthonormalize_righthanded(eig_v)
        molecule = molecule.basistransform(eig_v)
        return {'transformed_Cartesian': molecule, 'eigenvectors': eig_v,
                'diag_inertia_tensor': diag_inertia, 'inertia_tensor': inertia}