Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Yield Curve Chart: Fix Syntax Where Pandas Drops Column Name After reset_index() #6591

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ def create_fig(figure, df, dates, color_count, country: Optional[str] = None):
color = colors[color_count % len(colors)]
plot_df = df[df["date"] == date].copy()
plot_df["rate"] = plot_df["rate"].apply(lambda x: x * 100)
plot_df = plot_df.rename(columns={"rate": "Yield"})
plot_df = (
plot_df.drop(columns=["date"])
.set_index("maturity")
.filter(items=maturities, axis=0)
.reset_index()
.rename(columns={"maturity": "Maturity", "rate": "Yield"})
)
plot_df = plot_df.rename(columns={"index": "Maturity"})
plot_df["Maturity"] = [
(
d.split("_")[1] + " " + d.split("_")[0].title()
Expand Down Expand Up @@ -105,7 +106,7 @@ def create_fig(figure, df, dates, color_count, country: Optional[str] = None):

dates = df.date.unique().tolist()
figure, color_count = create_fig(figure, df, dates, color_count)
extra_params = kwargs.get("extra_params")
extra_params = kwargs.get("extra_params", {})
extra_params = (
extra_params if isinstance(extra_params, dict) else extra_params.__dict__
)
Expand Down
Loading