Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A Python package for generating customizable HTML and PDF reports from Pandas DataFrames and Jinja2 templates
Pandas Publisher allows you to generate HTML and PDF reports using Jinja2 templates and Pandas dataframes. The generated reports can be saved as HTML, PDF, or returned as an HTML string.
To install run the following after cloning this repo:
pip install -e .
import pandas as pd
from pandaspublisher import generate
# Create some sample DataFrames
df1 = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
df2 = pd.DataFrame({'C': [5, 6], 'D': [7, 8]})
# Use a dictionary to pass the DataFrames and their variable names
dataframes = {'dataframe1': df1, 'dataframe2': df2}
# Use the full path to the template file
template_path = "/Users/jasonflittner/code/PandasPublisher/examples/templates/modern_template.html"
output_file = 'output.html'
output_format = 'html' # The desired output format for the report, either 'html', 'pdf', or 'html_string'.
context = {
"title": "Sample Report",
"content": "This is a sample report generated using Pandas Publisher."
}
generate.report(template_path=template_path, dataframes=dataframes, output_format=output_format, output_filename=output_file, context=context)
The output_format parameter accepts the following values:
Create your Jinja2 templates using standard HTML and Jinja2 syntax. Use the keys from your dataframes dictionary to reference the respective dataframes in the template. For example:
<!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h1>{{ title }}</h1>
<p>{{ content }}</p>
<h2>DataFrame 1</h2>
<table>
<thead>
<tr>
{% for column in dataframe1.columns %}
<th>{{ column }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for _, row in dataframe1.iterrows() %}
<tr>
{% for cell in row %}
<td>{{ cell }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
<h2>DataFrame 2</h2>
<table>
<thead>
<tr>
{% for column in dataframe2.columns %}
<th>{{ column }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for _, row in dataframe2.iterrows() %}
<tr>
{% for cell in row %}
<td>{{ cell }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>
FAQs
A Python package for generating customizable HTML and PDF reports from Pandas DataFrames and Jinja2 templates
We found that pandaspublisher demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.