pir_pipeline.utils.MockData.MockData

class pir_pipeline.utils.MockData.MockData(year: int | list[int] = 2008, valid: bool = True)

Bases: object

Class for mocking PIR data.

__init__(year: int | list[int] = 2008, valid: bool = True)

Initialize attributes

Methods

__init__([year, valid])

Initialize attributes

data_specifications()

Set up data specifications

export([directory, how])

Export mock data

generate_data()

Store the mock data in an openpyxl Workbook object.

generate_rows(columns, type)

Generate mock data

Attributes

data

Data generated by export

sheets

List of mocked sheet names

workbooks

Dictionary of mocked workbooks

year

Year for which to mock data

property data

Data generated by export

data_specifications() Self

Set up data specifications

export(directory: str = None, how: str = None) Self

Export mock data

Mock data can be exported to a physical location by specifying the ‘directory’ argument. Otherwise specify ‘how’. One of ‘directory’ or ‘how’ must be specified but not both.

Args:

dir (str, optional): String path to a physical directory. Defaults to None. how (str, optional): String indicating how to export the data. Defaults to None. Can be one of: “ExcelFile”, “DataFrame”, “Insertable”. These options export the data as a pandas ExcelFile, dictionary of pandas DataFrames, or insertion-ready PIRIngestor object respectively.

Returns:

Self: Returns an object of class MockData.

generate_data() Self

Store the mock data in an openpyxl Workbook object.

Returns:

Self: Returns an object of class MockData.

generate_rows(columns: list[str], type: str) Self

Generate mock data

Parameters:

columns (list[str]): Columns to include in the mocked data type (str): The sheet type, one of self._specs[‘sheet’]

Returns:

Self: Returns an object of class MockData.

property sheets

List of mocked sheet names

property workbooks

Dictionary of mocked workbooks

property year

Year for which to mock data