Reading and iterating hovertemplate data from a different CSV file

Hi,

I have been able to plot multiple traces iterating over each column

df1 =pd.read_csv("CSV file with 29 columns first column is use for x-axis data, the rest 28 are used multiple traces (see below).csv")
data_questions=pd.read_csv("CSV file with two columns column1 (Question) has numbers 1 to 28, column 2 (Qtxt) has text for each Question(see below).csv")

fig = go.Figure()
traces={}
questions=data_questions['Qtxt']

for col in df.columns:
    traces['trace_' + col]=go.Bar(x=df['Levels'],
                                    y=df[col],
                                    name=col,
                                    customdata = data_questions['Qtext'],
                                    hovertemplate = "Question: %{customdata}%",
                                    #hovertext=questions,
                                    hoverinfo="text",
                                )

df_plot=list(traces.values())

# build figure
fig=go.Figure(df_plot)

fig.update_layout(title='Graph1',
                    xaxis_title="Level",
                    xaxis_dtick=1,
                    yaxis_title="Total number",
                    yaxis_dtick=1,
                    font=dict(
                        family="Courier New, monospace",
                        size=18,
                        color="#000000"
                )
)
fig.show()

The issue I am having, is the the Qtxt is for each trace and not each data point. The above code allocates each single bar, to each Question text.

Sample CSV data for main CSV file: df1
Levels, Q1, Q2, Q3…Q28
16, 0 , 3, 2
15, 3, 1, 5
14, 1, 2, 5
…
0, 1, 3, 4

Sample CSV data for second CSV file: data_questions
Question, Qtxt
1, This is the text for Q1
2, This is the text for Q2
3, This is the text for Q3
…
28, This is the text for Q28

Also, is there are way to prevent the first column from being plotted as trace (in this case Levels)

Thanks in advance!

@astro,

I suggest the following solution:

Define

questions  = list(data-questions['Qtxt'])
for k, col in enumerate( df.columns):
    if k > 0:
        traces[....] =

In the definition of each bar trace remove customdata, and hovertemplate and set

hovertext = questions[k]

Thanks @empet, I will implement this and let you know it goes.