def _expectation(self, data: pd.DataFrame) -> pd.DataFrame:
        """Calculates the expected value of the Pauli operator.

        Assuming that the data is measured in the Pauli basis of the operator,
        then the expectation of the Pauli operator would be +1 if the
        measurement is all ones and -1 if the measurement is all zeros.

        Args:
            data: measurement data to compute the expecation for.

        Returns:
            Data frame with columns 'delay_ns', 'num_pulses' and 'value'
            The num_pulses column will only exist if multiple pulses
            were requestd in the T2 experiment.
        """
        delay = data['delay_ns']
        ones = data[1]
        zeros = data[0]
        pauli_expectation = (2 * (ones / (ones + zeros))) - 1.0
        if 'num_pulses' in data.columns:
            return pd.DataFrame(
                {'delay_ns': delay, 'num_pulses': data['num_pulses'], 'value': pauli_expectation}
            )
        return pd.DataFrame({'delay_ns': delay, 'value': pauli_expectation})
Calculates the expected value of the Pauli operator.

        Assuming that the data is measured in the Pauli basis of the operator,
        then the expectation of the Pauli operator would be +1 if the
        measurement is all ones and -1 if the measurement is all zeros.

        Args:
            data: measurement data to compute the expecation for.

        Returns:
            Data frame with columns 'delay_ns', 'num_pulses' and 'value'
            The num_pulses column will only exist if multiple pulses
            were requestd in the T2 experiment.
        
cirq-core/cirq/experiments/t2_decay_experiment.py