Reporting
The SPAI library also contains a method to easily create reports with the aim of containing the results of the processed satellite images. It can be found in the reports
module.
/reports
|- generate.py
generate_report
Purpose: This function is designed to generate a detailed report based on the provided data. The report includes a plot of the specified type, optional text and title, and can include the data as a table. The report can also be zipped and saved to a specified output path.
def generate_report(
dataframe: Union[dict, pd.DataFrame],
plot_type: str,
output: Optional[str] = "report.pdf",
title: Optional[str] = None,
text: Optional[str] = None,
show_table: Optional[bool] = False,
zip: Optional[bool] = False,
) -> None:
Parameters:
dataframe
: Adict
orpd.DataFrame
containing the data to be included in the report. If adict
is passed, it should be in JSON format. If apd.DataFrame
is passed, it will be converted to JSON.plot_type
: Astr
indicating the type of plot to be generated and included in the report. This should correspond to one of the predefined plot types supported by the report generation system.output
(optional): Astr
specifying the path to the output file where the report will be saved. The default value is"report.pdf"
.title
(optional): Astr
representing the title of the report. If provided, it will be included at the top of the report.text
(optional): Astr
containing additional text to be included in the report, such as a description or commentary on the data.show_table
(optional): Abool
indicating whether to include a table in the report that displays the data from thedataframe
. The default value isFalse
.zip
(optional): Abool
indicating whether to compress the resulting report file into a ZIP format. The default value isFalse
.
Returns: The function does not return any value, but it creates a report file at the specified output
location.
Examples:
# Create a simple DataFrame
import pandas as pd
data = {'Column1': [1, 2, 3], 'Column2': [4, 5, 6]}
dataframe = pd.DataFrame(data)
# Generate a report with a pie chart, a title, and without a data table
generate_report(dataframe, plot_type='pie', title='My Pie Chart Report')
# Generate a report with a bar chart, a title, additional text, and with the data table included
generate_report(dataframe, plot_type='bar', title='Bar Chart Report', text='This is an important report.', show_table=True, output='my_report.pdf')
Troubleshooting
If you encounter any issues during the installation of SPAI, please get in touch with use through our Discord server.
Back to top