Introduction
Creating publication-ready tables is part of the long and tedious process of research. Fortunately, Julius makes this process easy with a couple of simple prompts! This guide will walk you though how to create these tables seamlessly with the help of Julius!
Step-by-step Walkthrough
Step 1: Upload your dataset
The first step to any data analysis is to upload it to Julius. If you do not have a dataset to work with, you can use this sample dataset. Below is the example of the sample dataset:
Treatment | Response Rate (%) | Standard Error | Sample Size | p-value |
---|---|---|---|---|
Control | 45.2 | 2.1 | 100 | 0.324 |
Low Dose | 62.7 | 1.8 | 100 | 0.012 |
Medium Dose | 78.4 | 1.5 | 100 | 0.001 |
High Dose | 89.1 | 1.2 | 100 | 0.0001 |
Prompt 1
‘Please Preview File.’
Here is Julius’s output:
Step 2: Ask Julius to use ‘IPython.display’
We will achieve this publication-ready table by using the HTML code provided by Julius. After that, we can use the code provided to convert it to a PDF document. If this is still unclear, just bear with me.
Prompt 2
‘I want to make an HTML table from IPython.display. Needs to be formatted under the publication guidelines. Do you know what that is?’
Here is the response I got from Julius:
In the images above, we can see that Julius understood my inquiry about creating a publication-ready table. The only thing that I would change would be to add a caption at the top of the table indicating the table number and a brief description of its contents. I could also adjust the column width to fit the contents better.
Step 3: Paste HTML Code into Reader (Optional)
You can take the image that Julius produced from the thread itself, or you can copy and paste the HTML code into an HTML reader. I found a simple website that converts the code into a PDF, which can be accessed here.
HTML Code Julius
Pasted Code in Website
Now you can easily create publication-ready tables with Julius! Interested in trying it out yourself? Check out this workflow.
Python & HTML Code
Entire Python Code
from IPython.display import HTML
import pandas as pd
import numpy as np
# Read the data
df = pd.read_excel('Example_dataset_HTML.xlsx')
# Function to add significance stars based on p-value
def add_significance(p_value):
if p_value <= 0.0001:
return '****'
elif p_value <= 0.001:
return '***'
elif p_value <= 0.01:
return '**'
elif p_value <= 0.05:
return '*'
return 'ns'
# Format the data with proper precision
df['Response Rate'] = df['Response Rate (%)'].apply(lambda x: f"{x:.1f} \u00b1 {df.loc[df['Response Rate (%)'] == x, 'Standard Error'].iloc[0]:.1f}")
df['Significance'] = df['p-value'].apply(add_significance)
# Create HTML table with publication styling
html_table = '''
<style>
table.publication {
border-collapse: collapse;
width: 100%;
margin: 20px 0;
font-family: Arial, sans-serif;
font-size: 12px;
}
.publication th {
border-top: 2px solid black;
border-bottom: 2px solid black;
padding: 12px;
text-align: left;
font-weight: bold;
background-color: #f8f8f8;
}
.publication td {
border-bottom: 1px solid #ddd;
padding: 12px;
text-align: left;
}
.publication tr:last-child td {
border-bottom: 2px solid black;
}
.publication caption {
caption-side: bottom;
text-align: left;
font-size: 11px;
padding: 10px 0;
}
</style>
'''
# Create the table content
html_table += '<table class="publication">'
html_table += '<caption>Note: *p \u2264 0.05, **p \u2264 0.01, ***p \u2264 0.001, ****p \u2264 0.0001, ns = not significant. Values shown as mean \u00b1 SE.</caption>'
html_table += '''
<tr>
<th>Treatment Group</th>
<th>Response Rate (%)</th>
<th>Sample Size</th>
<th>Statistical Significance</th>
</tr>
'''
for _, row in df.iterrows():
html_table += f'''
<tr>
<td>{row['Treatment']}</td>
<td>{row['Response Rate']}</td>
<td>{int(row['Sample Size'])}</td>
<td>{row['Significance']}</td>
</tr>
'''
html_table += '</table>'
# Display the table
display(HTML(html_table))
print("Table generated with publication formatting")
Enitre HTML Code
<style>
table.publication {
border-collapse: collapse;
width: 100%;
margin: 20px 0;
font-family: Arial, sans-serif;
font-size: 12px;
}
.publication th {
border-top: 2px solid black;
border-bottom: 2px solid black;
padding: 12px;
text-align: left;
font-weight: bold;
background-color: #f8f8f8;
}
.publication td {
border-bottom: 1px solid #ddd;
padding: 12px;
text-align: left;
}
.publication tr:last-child td {
border-bottom: 2px solid black;
}
.publication caption {
caption-side: bottom;
text-align: left;
font-size: 11px;
padding: 10px 0;
}
</style>
<table class="publication">
<caption>Note: *p \u2264 0.05, **p \u2264 0.01, ***p \u2264 0.001, ****p \u2264 0.0001, ns = not significant. Values shown as mean \u00b1 SE.</caption>
<tr>
<th>Treatment Group</th>
<th>Response Rate (%)</th>
<th>Sample Size</th>
<th>Statistical Significance</th>
</tr>
<tr>
<td>Control</td>
<td>45.2 \u00b1 2.1</td>
<td>100</td>
<td>ns</td>
</tr>
<tr>
<td>Low Dose</td>
<td>62.7 \u00b1 1.8</td>
<td>100</td>
<td>**</td>
</tr>
<tr>
<td>Medium Dose</td>
<td>78.4 \u00b1 1.5</td>
<td>100</td>
<td>***</td>
</tr>
<tr>
<td>High Dose</td>
<td>89.1 \u00b1 1.2</td>
<td>100</td>
<td>****</td>
</tr>
</table>
Sources:
Online Viewer. (n.d.). HTML online viewer. Retrieved November 7, 2024, from https://html.onlineviewer.net/