0

I am trying to visualize a dataframe with bokeh in Python. This is what my dataframe looks like:

link to dataframe

I use the following code to generate a line chart:

visualized_result.plot_bokeh(kind='line', x='x', y=['y', 'y38'], xlabel='x-values', ylabel='functions', title='Best Function')

Now I am getting the following Error:

Exception                                 Traceback (most recent call last)
<ipython-input-50-6fd221ec89a7> in <module>
----> 1 visualized_result.plot_bokeh(kind='line', x='x', y=['y', 'y38'], xlabel='x-values', ylabel='functions', title='Best Function')

~/opt/anaconda3/lib/python3.8/site-packages/pandas_bokeh/plot.py in __call__(self, *args, **kwargs)
   1785 
   1786     def __call__(self, *args, **kwargs):
-> 1787         return plot(self.df, *args, **kwargs)
   1788 
   1789     @property

~/opt/anaconda3/lib/python3.8/site-packages/pandas_bokeh/plot.py in plot(df_in, x, y, kind, figsize, use_index, title, legend, logx, logy, xlabel, ylabel, xticks, yticks, xlim, ylim, fontsize_title, fontsize_label, fontsize_ticks, fontsize_legend, color, colormap, category, histogram_type, stacked, weights, bins, normed, cumulative, show_average, plot_data_points, plot_data_points_size, number_format, disable_scientific_axes, show_figure, return_html, panning, zooming, sizing_mode, toolbar_location, hovertool, hovertool_string, rangetool, vertical_xlabel, x_axis_location, webgl, reuse_plot, **kwargs)
    342                 )
    343         else:
--> 344             raise Exception(
    345                 "Please provide for the <x> parameter either a column name of the DataFrame/Series or an array of the same length."
    346             )

Exception: Please provide for the <x> parameter either a column name of the DataFrame/Series or an array of the same length.

Can anybody help me what is going on here? I have a feeling that this should actually be quite simple. Thanks so much for your help

Kata
  • 1
  • 2
  • Please don't post images of code, data, or Tracebacks. Copy and paste it as text then format it as code (select it and type `ctrl-k`) ... [Discourage screenshots of code and/or errors](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors)...[Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question) . – wwii May 30 '21 at 15:14
  • [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – wwii May 30 '21 at 15:15
  • From your image, `x` looks like the index - try dropping the `x='x'` argument - [the docs](https://patrikhlobil.github.io/Pandas-Bokeh/#advanced-lineplot) say it will default to the index. ... `visualized_result.plot_bokeh(kind='line', y=['y', 'y38'], xlabel=...` – wwii May 30 '21 at 15:24

0 Answers0