Dataframe cannot be called in ui.plot_card

I am importing data using pandas and then trying to plot it using ui.plot_card function. But it says it Dataframe is not callable.
What object type is callable in the ui.plot_card parameter ?
I converted it into list also but didn’t work
I tried Data buffer also but that too didn’t work
Is there any example in the documentation that does not use the from synth import FakeScatter library or without using from h2o_wave import data ?

Thank you !

1 Like

Hi Aniket!

You can use the tolist() function of df.columns and df.values along with data(fields, rows) object to plot pandas data frames.

q.page['my_plot'] = ui.plot_card(
   box='1 1 4 4',
   title='Scatter Plot from Dataframe',
   data=data(
      fields=df.columns.tolist(), 
      rows=df.values.tolist(),
   ),
   plot=ui.plot(marks=[ui.mark(type='point', x='=col_1', y='=col_2')])
)

Here’s a Wave script that preps a dataframe using pandas and then builds a few different plots: https://gist.github.com/mtanco/43f80c8c219aea52d8a708f05be21bb1

Hope this helps!

1 Like

Hi @mtanco

Thanks for replying.
The solution provided by you worked for me.
Thanks a lot !

Regards,
Aniket