Posts

Showing posts with the label plotly-dash

AttributeError: module 'dash.dash' has no attribute 'dependencies'

AttributeError: module 'dash.dash' has no attribute 'dependencies' Below is my error, Traceback (most recent call last): File "app.py", line 54, in dash.dependencies.Output('react-graph','figure'), AttributeError: module 'dash.dash' has no attribute 'dependencies' Below are my imports, from dash import dash import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output import plotly.graph_objs as go import psycopg2 import os import flask Below is my callback function @app.callback( dash.dependencies.Output('react-graph','figure'), [dash.dependencies.Input('reg_col','value')] ) I do not have any file named dash.py in my current directory. I have also tried to change to the import dash from dash to just import dash. The former gives me the below error. Dash was not successfully imported. Make sure you don't have a file named 'dash...

Python/Dash by Plotly: Group cases by date

Python/Dash by Plotly: Group cases by date I got to plot barchart only for total cases of occurences and not group cases by date of occurences with this code: trace1=go.Bar( x=pd.to_datetime(dfb['date']), y=dfb.set_index('date').resample('M')["enrolled"].sum(), ) How to do groupby date? Dataset as below date enrolled 6/29/2018 1 6/29/2018 1 6/29/2018 6/29/2018 1 6/20/2018 1 6/22/2018 1 6/19/2018 1 6/27/2018 1 6/28/2018 6/27/2018 1 6/19/2018 1 6/20/2018 1 6/27/2018 1 6/27/2018 6/26/2018 1 6/27/2018 6/27/2018 1 Thanks 3 Answers 3 I used the following content in my data.csv : data.csv date enrolled 6/29/2018 1 6/29/2018 1 6/29/2018 0 6/29/2018 1 6/20/2018 1 6/22/2018 1 6/19/2018 1 6/27/2018 1 6/28/2018 0 6/27/2018 1 6/19/2018 1 6/20/2018 1 6/27/2018 1 6/27/2018 0 6/26/2018 1 6/27/2018 0...

Unable To Plot Graph From PostgreSQL Query Results In Dash App

Unable To Plot Graph From PostgreSQL Query Results In Dash App I am attempting to write a simple code to simply plot a bar graph of some fruit names in the x-axis vs corresponding sales units. The aim of this code is just to understand how to query postgres results from heroku hosted database through a dash app. Below is the code, from dash import dash import dash_core_components as dcc import dash_html_components as html import plotly.graph_objs as go import psycopg2 import os DATABASE_URL = os.environ['DATABASE_URL'] conn = psycopg2.connect(DATABASE_URL, sslmode='require') cur = conn.cursor() cur.execute("SELECT fruits FROM pgrt_table") fruits1=cur.fetchall() #print(fruits1) cur.execute("SELECT sales FROM pgrt_table") sales1=cur.fetchall() app = dash.Dash() app.layout = html.Div(children=[ html.H1( children='Hello Dash' ), html.Div( children='''Dash: A web application framework for Python.''...