Try .reset_index()
first, and then use method .tolist()
. Like this:
df_duration_means = df_duration_means.reset_index()
duration = df_duration_means.index.tolist()
interest = df_duration_means['Interest'].tolist()
loan_amount = df_duration_means['Loan amount'].tolist()
ltv = df_duration_means['LTV'].tolist()
And then, use duration
, interest
, loan_amount
, and ltv
as an input into plotly
EDIT: There is simpler solution using plotly.express:
import plotly.express as px
df_duration_means = df_duration_means.reset_index()
fig = px.line(df_duration_means, x=df_duration_means.index, y=['Interest', 'Loan amount', 'LTV'])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…