---
title: PauliExpectation (v0.46)
description: API reference for qiskit.opflow.expectations.PauliExpectation in qiskit v0.46
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/0.46/qiskit.opflow.expectations.PauliExpectation
---

# PauliExpectation

*class* `qiskit.opflow.expectations.PauliExpectation(group_paulis=True)`

[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.46/qiskit/opflow/expectations/pauli_expectation.py)

Bases: [`ExpectationBase`](/docs/api/qiskit/0.46/qiskit.opflow.expectations.ExpectationBase "qiskit.opflow.expectations.expectation_base.ExpectationBase")

An Expectation converter for Pauli-basis observables by changing Pauli measurements to a diagonal (\{Z, I}^n) basis and appending circuit post-rotations to the measured state function. Optionally groups the Paulis with the same post-rotations (those that commute with one another, or form Abelian groups) into single measurements to reduce circuit execution overhead.

> **Deprecated since version 0.24.0**
>
> The class `qiskit.opflow.expectations.pauli_expectation.PauliExpectation` is deprecated as of qiskit-terra 0.24.0. It will be removed in the Qiskit 1.0 release. For code migration guidelines, visit [https://qisk.it/opflow\_migration](https://qisk.it/opflow_migration).

**Parameters**

**group\_paulis** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – Whether to group the Pauli measurements into commuting sums, which all have the same diagonalizing circuit.

## Methods

### compute\_variance

`compute_variance(exp_op)`

Compute the variance of the expectation estimator.

**Parameters**

**exp\_op** ([*OperatorBase*](/docs/api/qiskit/0.46/qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")) – The full expectation value Operator after sampling.

**Returns**

The variances or lists thereof (if exp\_op contains ListOps) of the expectation value estimation.

**Return type**

[list](https://docs.python.org/3/library/stdtypes.html#list) | [float](https://docs.python.org/3/library/functions.html#float) | [*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)

### convert

`convert(operator)`

Accepts an Operator and returns a new Operator with the Pauli measurements replaced by diagonal Pauli post-rotation based measurements so they can be evaluated by sampling and averaging.

**Parameters**

**operator** ([*OperatorBase*](/docs/api/qiskit/0.46/qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")) – The operator to convert.

**Returns**

The converted operator.

**Return type**

[*OperatorBase*](/docs/api/qiskit/0.46/qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")
