Skip to main content
Version: 1.3.7

Batch

Signature

class great_expectations.datasource.fluent.interfaces.Batch(datasource: Datasource, data_asset: DataAsset, batch_request: BatchRequest, data: BatchData, batch_markers: BatchMarkers, batch_spec: BatchSpec, batch_definition: LegacyBatchDefinition, metadata: Dict[str, Any] | None = None)

This represents a batch of data.

This is usually not the data itself but a hook to the data on an external datastore such as a spark or a sql database. An exception exists for pandas or any in-memory datastore.

Methods

Signature

columns() → List[str]

Return column names of this Batch.

Returns

TypeDescription

List[str]

list of column names.

Signature

head(n_rows: pydantic.v1.types.StrictInt = 5, fetch_all: pydantic.v1.types.StrictBool = False) → great_expectations.datasource.fluent.interfaces.HeadData

Return the first n rows of this Batch.

This method returns the first n rows for the Batch based on position.

For negative values of n_rows, this method returns all rows except the last n rows.

If n_rows is larger than the number of rows, this method returns all rows.

Parameters

NameDescription

n_rows

The number of rows to return from the Batch.

Returns

TypeDescription

great_expectations.datasource.fluent.interfaces.HeadData

HeadData

Signature

validate(expect: Expectation, *, result_format: ResultFormatUnion = 'DEFAULT_RESULT_FORMAT', expectation_parameters: Optional[SuiteParameterDict] = 'None') → ExpectationValidationResult
Signature

validate(expect: ExpectationSuite, *, result_format: ResultFormatUnion = 'DEFAULT_RESULT_FORMAT', expectation_parameters: Optional[SuiteParameterDict] = 'None') → ExpectationSuiteValidationResult

Validate the Batch using the provided Expectation or Expectation Suite.

Parameters

NameDescription

expect

The Expectation or Expectation Suite to validate.

Returns

TypeDescription

ExpectationSuiteValidationResult

An ExpectationValidationResult or ExpectationSuiteValidationResult object.

Raises

TypeDescription

ValueError

If the expect argument is not an Expectation or an ExpectationSuite.