reports#

class analytix.reports.Report(data: dict[t.Any, t.Any], type: ReportType)#

A class representing a YouTube Analytics API report. You will never need to manually create an instance of this.

Parameters
  • data – The raw data retrieved from the API.

  • type – The report type.

property shape: tuple[int, int]#

The shape of the report in the format (rows, columns).

to_dataframe(*, skip_date_conversion: bool = False) pd.DataFrame#

Export the report data to a pandas or Modin DataFrame. If you wish to use Modin, you are responsible for selecting and initialising your desired engine.

Keyword Arguments

skip_date_conversion – Whether to skip automatically converting date columns to the datetime64[ns] format. Defaults to False.

Returns

The newly created DataFrame.

to_arrow_table(*, skip_date_conversion: bool = False) pa.Table#

Export the report data to an Apache Arrow Table.

Keyword Arguments

skip_date_conversion – Whether to skip automatically converting date columns to the datetime64[ns] format. Defaults to False.

Returns

The newly constructed Apache Arrow Table.

New in version 3.2.0.

to_json(path: str, *, indent: int = 4) analytix.reports.JSONReportWriter#

Write the report data to a JSON file.

Note

This method can also be run asynchronously by awaiting it.

Parameters

path – The path the file should be saved to.

Keyword Arguments

indent – The amount of indentation the data should be written with. Defaults to 4.

Returns

The report writer. This is done to allow this method to run sync or async in a typed context.

to_csv(path: str, *, delimiter: str = ',') analytix.reports.CSVReportWriter#

Write the report data to a CSV file.

Note

This method can also be run asynchronously by awaiting it.

Parameters

path – The path the file should be saved to.

Keyword Arguments

delimiter – The delimiter to use. Defaults to a comma. Passing a tab here will save the file as a TSV instead.

Returns

The report writer. This is done to allow this method to run sync or async in a typed context.

to_excel(path: str, *, sheet_name: str = 'Analytics') None#

Write the report data to an Excel spreadsheet.

Parameters

path – The path the file should be saved to.

Keyword Arguments

sheet_name – The name for the worksheet.

New in version 3.1.0.

to_feather(path: str) None#

Write the report data to an Apache Feather file.

Parameters

path – The path the file should be saved to.

New in version 3.2.0.

to_parquet(path: str) None#

Write the report data to an Apache Parquet file.

Parameters

path – The path the file should be saved to.

New in version 3.2.0.