diff --git a/New Text Document.txt b/New Text Document.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/README.md b/README.md index 7ee65c0ab1..f4cc4ad8e8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,45 @@ -# Quantium starter repo -This repo contains everything you need to get started on the program! Good luck! +import pandas as pd +import dash +from dash import dcc, html +from dash.dependencies import Input, Output +import plotly.express as px + +# Read the CSV file containing sales data +sales_data = pd.read_csv('https://gist.githubusercontent.com/chriddyp/c78bf172206ce24f77d6363a2d754b59/raw/c353e8ef842413cae56ae3920b8fd78468aa4cb2/usa-agricultural-exports-2011.csv') + + +# Convert 'date' column to datetime +sales_data['date'] = pd.to_datetime(sales_data['date']) + +# Sort data by date +sales_data = sales_data.sort_values(by='date') + +# Initialize the Dash app +app = dash.Dash(__name__) + +# Define the layout of the app +app.layout = html.Div([ + html.H1("Pink Morsel Sales Visualizer"), + dcc.Graph(id='sales-chart'), +]) + +# Define callback to update the chart based on user input +@app.callback( + Output('sales-chart', 'figure'), + [Input('sales-chart', 'hoverData')] +) +def update_chart(hoverData): + # Filter data before and after the price increase + before_increase = sales_data[sales_data['date'] < '2021-01-15'] + after_increase = sales_data[sales_data['date'] >= '2021-01-15'] + + # Create line chart + fig = px.line(sales_data, x='date', y='Sales', title="Sales Before and After Pink Morsel Price Increase") + + # Highlight the price increase date + fig.add_vline(x='2021-01-15', line_dash="dash", annotation_text="Price Increase", annotation_position="top right") + + return fig + +if __name__ == '__main__': + app.run_server(debug=True) diff --git a/app.py b/app.py new file mode 100644 index 0000000000..ac0dcb9374 --- /dev/null +++ b/app.py @@ -0,0 +1,35 @@ +# Run this app with `python app.py` and +# visit http://127.0.0.1:8050/ in your web browser. + + +from dash import Dash, html, dcc +import plotly.express as px +import pandas as pd + +app = Dash(__name__) + +# assume you have a "long-form" data frame +# see https://plotly.com/python/px-arguments/ for more options +df = pd.DataFrame({ + "Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"], + "Amount": [4, 1, 2, 2, 4, 5], + "City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"] +}) + +fig = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group") + +app.layout = html.Div(children=[ + html.H1(children='Hello Dash'), + + html.Div(children=''' + Dash: A web application framework for your data. + '''), + + dcc.Graph( + id='example-graph', + figure=fig + ) +]) + +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file diff --git a/script.py b/script.py new file mode 100644 index 0000000000..374556203d --- /dev/null +++ b/script.py @@ -0,0 +1,27 @@ +import pandas as pd + +# Read CSV files +df1 = pd.read_csv('data/file1.csv') +df2 = pd.read_csv('data/file2.csv') +df3 = pd.read_csv('data/file3.csv') + +# Filter rows by product +df1 = df1[df1['product'] == 'Pink Morsels'] +df2 = df2[df2['product'] == 'Pink Morsels'] +df3 = df3[df3['product'] == 'Pink Morsels'] + +# Create 'Sales' column +df1['Sales'] = df1['quantity'] * df1['price'] +df2['Sales'] = df2['quantity'] * df2['price'] +df3['Sales'] = df3['quantity'] * df3['price'] + +# Keep only required columns +df1 = df1[['Sales', 'date', 'region']] +df2 = df2[['Sales', 'date', 'region']] +df3 = df3[['Sales', 'date', 'region']] + +# Concatenate DataFrames +result = pd.concat([df1, df2, df3]) + +# Write to output CSV file +result.to_csv('output.csv', index=False)