Need help on error: "All arguments should have the same length."

I’m trying to plot a time series using plotly express line chart. The data frame has 2 column index levels:

Variable Futures VIX9D_Basis … VIX3M_Basis GVZ_Basis
1.0 1.5 1.5 2.0 3.0 4.0 5.0 6.0 1.0 1.5 … 5.0 6.0 1.0 1.5 1.5 2.0 3.0 4.0 5.0 6.0
Trade Date

The top level is a string, the 2nd level is an integer.

When I try to plot one of the columns:

fig1 = px.line(vix_basis, x=vix_basis.index, y=(‘VIX_Basis’, ‘1.0’), title=‘VIX basis’)
fig.show()

I get the error message:

All arguments should have the same length. The length of argument y is 2, whereas the length of previously-processed arguments [‘Trade Date’] is 5007

Please note ‘Trade Date’ is the index column.

Why is plotly not able to pull the full column for the y axis? Is the fact that there is an integer as the 2nd level column name messing it up? Thanks!

Hey @vpansare welcome to the forums.

Could you please share your data in a way that people willing to help you can just copy & paste the code to create the figure or get the error message?

just pass the name name of the column to y. For example if you have a column named VIX_Basis, then y=‘VIX_Basis’ is what you want to pass to y. Your df length is 5007 that is why there are 5007 index count. And you are passing a tuple to y that is why complaining of 2. Just pass the name of the column as above which will also have 5007 values.