Пример #1
0
def update_function(dropdown_input_value, slider_price):

    # filter the dataframe
    df = data_wrangling(dropdown_input_value, slider_price)

    # use that dataframe in the figure
    fig = px.scatter_3d(
        df,
        x='TSNE1',
        y='TSNE2',
        z='TSNE3',
        color='price_category',
        hover_name='name',
        hover_data=['price', 'bedrooms', 'minimum_nights', 'id'],
        template='plotly_dark',
        opacity=0.9,
        title='Visualizing airbnb locations in feature space',
        labels={
            'TSNE1': 'X',
            'TSNE2': 'Y',
            'TSNE3': 'Z'
        })

    return fig
Пример #2
0
from worldbankapp import app
from flask import render_template
import pandas as pd
from wrangling_scripts.wrangling import data_wrangling

import plotly.graph_objs as go
import plotly, json

data = data_wrangling()

print(data[0])
# print(data)

country = data[0][0]
x_val = data[0][1]
y_val = data[0][2]

graph_one = [
    go.Scatter(x=data[0][1], y=data[0][2], mode='lines', name=country)
]

layout_one = dict(
    title='Change in Hectares Arable Land <br> prt Person 1990 to 2015',
    xaxis=dict(title='Year', autotick=False, tick0=1990, dtick=25),
    yaxis=dict(title='Hectares'))

figures = []
figures.append(dict(data=graph_one, layout=layout_one))

ids = ['figure-{}'.format(i) for i, _ in enumerate(figures)]
Пример #3
0
from flask import Flask, render_template
from wrangling_scripts.wrangling import data_wrangling
from wrangling_scripts.functions.functions import sort_graph_values, make_graph_layout

import plotly.graph_objs as go
import plotly, json

# creating the dataframes

column_names = ['LanguageWorkedWith', 'LanguageDesireNextYear']
df_worked, df_desired = data_wrangling(column_names)

# creating graph_one

sorty_one, sortx_one = sort_graph_values(df_worked, 'Used in 2019')
graph_one, layout_one = make_graph_layout(sortx_one, sorty_one, 'Top 10 Most Used Languages in 2019', 'Percentage', 'Language')

# creating graph two

sorty_two, sortx_two = sort_graph_values(df_desired, 'Desired for 2020')
graph_two, layout_two = make_graph_layout(sortx_two, sorty_two, 'Top 10 Most Desired Languages for 2020', 'Percentage', 'Language')

# appending grahps and layouts

figures = []
figures.append(dict(data=graph_one, layout=layout_one))
figures.append(dict(data=graph_two, layout=layout_two))


ids = ['figure-{}'.format(i) for i, _ in enumerate(figures)]
figuresJSON = json.dumps(figures, cls=plotly.utils.PlotlyJSONEncoder)
""" routes.py - Flask route definitions

Flask requires routes to be defined to know what data to provide for a given
URL. The routes provided are relative to the base hostname of the website, and
must begin with a slash."""
from flaskapp import app
from flask import render_template
from wrangling_scripts.wrangling import data_wrangling, username

data, datapy = data_wrangling()


# The following two lines define two routes for the Flask app, one for just
# '/', which is the default route for a host, and one for '/index', which is
# a common name for the main page of a site.
#
# Both of these routes provide the exact same data - that is, whatever is
# produced by calling `index()` below.
@app.route('/')
@app.route('/index')
def index():
    """Renders the index.html template"""
    # Renders the template (see the index.html template file for details). The
    # additional defines at the end (table, header, username) are the variables
    # handed to Jinja while it is processing the template.
    return render_template('index.html', data=data, datapy=datapy)
Пример #5
0
""" routes.py - Flask route definitions

Flask requires routes to be defined to know what data to provide for a given
URL. The routes provided are relative to the base hostname of the website, and
must begin with a slash."""
from flaskapp import app
from flask import render_template
from wrangling_scripts.wrangling import data_wrangling, username

header, table = data_wrangling()

# The following two lines define two routes for the Flask app, one for just
# '/', which is the default route for a host, and one for '/index', which is
# a common name for the main page of a site.
#
# Both of these routes provide the exact same data - that is, whatever is
# produced by calling `index()` below.
@app.route('/')
@app.route('/index')
def index():
    """Renders the index.html template"""
    # Renders the template (see the index.html template file for details). The
    # additional defines at the end (table, header, username) are the variables
    # handed to Jinja while it is processing the template.
    return render_template('index.html', table=table, header=header,
                           username=username())
Пример #6
0
from flaskapp import app
from flask import render_template
import pandas as pd
from wrangling_scripts.wrangling import data_wrangling

data, df = data_wrangling()

print(data)


@app.route('/')
@app.route('/index')
def index():
    return render_template('index.html',
                           tables=[df.to_html(classes='data', header="true")])


@app.route('/project-one')
def project_one():
    return render_template('project_one.html')
Пример #7
0
# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd
from wrangling_scripts.wrangling import data_wrangling
from dash.dependencies import Input, Output

# get the data from backend, these are defaults
df = data_wrangling('Chelsea', 0)

# define your stylesheet
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

# this is needed for the procfile to deploy to heroku
server = app.server

# Sample markdown text
markdown_text = '''
### Select the **neighbourhood** from the dropdown
'''

app.layout = html.Div(children=[
    html.H1(children='Find similar Airbnb locations in New York City'),
    html.Div([dcc.Markdown(children=markdown_text)]),
    html.Div([
        dcc.Dropdown(id='dropdown',
                     options=[{
Пример #8
0
from flask import Flask, render_template
from wrangling_scripts.wrangling import data_wrangling

import plotly.graph_objs as go
import plotly, json

df_2019 = data_wrangling()

print([
    x for _, x in sorted(zip(df_2019['Used in 2019'][:10], df_2019.index[:10]))
])