Skip to content

Instantly share code, notes, and snippets.

@r-brink
Last active February 5, 2024 08:15
Show Gist options
  • Save r-brink/b0e491df376b78795dc4eac3d38023f2 to your computer and use it in GitHub Desktop.
Save r-brink/b0e491df376b78795dc4eac3d38023f2 to your computer and use it in GitHub Desktop.
import hvplot
import pandas as pd
import polars as pl
def read_excel_plot():
df = pl.read_csv("output/read_excel_results.csv")
df = df.with_columns(
df["Engine"]
.map_elements(
lambda engine: {
f"Pandas {pd.__version__}": "#F9CFF2",
"xlsx2csv": "#73bfb8",
"openpyxl": "#26413c",
"calamine (new)": "#0075FF",
}.get(engine)
)
.alias("color")
)
plot = df.plot.bar(
x="Engine",
y="Time",
color="color",
ylabel="Time (seconds)",
title="Reading Excel performance comparison w/ different engines",
)
plot = plot.redim.values(
Engine=["calamine (new)", "openpyxl", "xlsx2csv", f"Pandas {pd.__version__}"]
)
return hvplot.save(plot, "output/read_excel_plot.html")
read_excel_plot()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment