def process_results(
    mapping: dict[cirq.Qid, cirq.Qid],
    parity_mapping: dict[cirq.Qid, cirq.Qid],
    trial_result: cirq.Result,
) -> pd.DataFrame:
    """Checks the given results for parity and throws away all of the runs that
    don't pass the parity test.

    Args:
        mapping: The circuit's mapping from logical qubit to physical qubit.
        parity_mapping: The mapping from result qubit to its parity qubit.
        trial_result: The results to process.

    Returns:
        Returns the rows that passed the parity test, with the parity qubit
        measurements removed.

    """
    # The circuit's mapping from physical qubit to logical qubit.
    inverse_mapping: dict[cirq.Qid, cirq.Qid] = {v: k for k, v in mapping.items()}

    # Calculate all the invalid parity pairs.
    data = trial_result.data
    bad_measurements: set[int] = set()
    for final_qubit, original_qubit in mapping.items():
        if original_qubit in parity_mapping:
            final_parity_qubit = inverse_mapping[parity_mapping[original_qubit]]
            mismatches = np.nonzero(
                np.atleast_1d(data[str(final_qubit)] == data[str(final_parity_qubit)])
            )
            bad_measurements.update(*mismatches)

    # Remove the parity qubits from the measurements.
    for parity_qubit in parity_mapping.values():
        data.drop(str(inverse_mapping[parity_qubit]), axis=1, inplace=True)

    print(f"Dropping {len(bad_measurements)} measurements")
    data.drop(bad_measurements, inplace=True)

    return data
Checks the given results for parity and throws away all of the runs that
    don't pass the parity test.

    Args:
        mapping: The circuit's mapping from logical qubit to physical qubit.
        parity_mapping: The mapping from result qubit to its parity qubit.
        trial_result: The results to process.

    Returns:
        Returns the rows that passed the parity test, with the parity qubit
        measurements removed.

    
cirq-core/cirq/contrib/quantum_volume/quantum_volume.py