I am trying to create an interactive bar plot. I have the following dataframe:
CustID| Age |Gender|Smoking_history |Alcohol_history
1 |18-24| M | Non-smoker | <21 units per week
2 |43-48| F | Non-smoker | <21 units per week
3 |37-42| M | Unknown | <21 units per week
4 |18-24| F | Unknown | Unknown
5 |43-48| M | Previous smoker | <21 units per week
I want to create an interactive plot where I can select columns and it can create a bar plot based on group by of the selected columns, i.e. total numbers by counting rows based on the group.
It shows two drop-down lists where the desired columns can be selected.
from plotly.offline import iplot, init_notebook_mode
import plotly.graph_objs as go
init_notebook_mode()
import plotly
@interact
def bar_plot(x=list([['Age', 'Gender', 'Smoking history', 'Alcohol
history']]), y=list(df[['Gender', 'Smoking history', 'Alcohol
history']])):
df.iplot(kind='bar', x=x, y=y,
xTitle=x.title(), yTitle=y.title(),
title=f'{y.title()} vs {x.title()}')
But it does not create any output. Instead it shows the error:
"C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\display.py:689:
UserWarning:
Consider using IPython.display.IFrame instead"
Any idea to resolve it?