My dataframe consists of two columns, the shareprice in every workday and the eps. The shareprice is only available on workdays, while the eps is only available quarterly on a saturday. Now I want to plot both graphs in the same visualization, with two y-axes.
close eps
date
...
2020-04-01 240.91 NaN
2020-03-31 254.29 NaN
2020-03-30 254.81 NaN
2020-03-28 NaN 2.59
2020-03-27 247.74 NaN
2020-03-26 258.44 NaN
...
2019-12-28 NaN 5.04
2019-12-27 289.80 NaN
...
My approach so far is using plotly:
fig = make_subplots(specs=[[{"secondary_y": True}]])
fig.add_trace(
go.Scatter(
x=df.index,
y=df["close"],
name = "Price"
),
secondary_y = False,
)
fig.add_trace(
go.Scatter(
x=df.dropna(subset=["eps"]),
y=df["eps"],
name = "EPS",
),
secondary_y = True,
)
fig.update_yaxes(
title_text="Price",
secondary_y=False
)
fig.update_yaxes(
title_text="EPS",
secondary_y=True,
)
fig.show()
However, I end up with a graph, but the EPS are not shown. I want eps, to be a line of connected dots, for all the missing datapoints in the eps column.


