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_json(path: str, *, indent: int = 4) None#

Write the report data to a JSON file.

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.

async ato_json(path: str, *, indent: int = 4) None#

Asynchronously write the report data to a JSON file.

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.

to_csv(path: str, *, delimiter: str = ',') None#

Write the report data to a CSV file.

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.

async ato_csv(path: str, *, delimiter: str = ',') None#

Asynchronously write the report data to a CSV file.

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.

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

Export the report data to a pandas DataFrame.

Note

The pandas library is required to do this, but is not automatically installed by analytix.

Keyword Arguments

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