Analyzing US Economic Data and Building a Dashboard

Analyzing US Economic Data and Building a Dashboard

December 28, 2019 ( last updated : July 01, 2017 )
DataScience Data Analysis

https://github.com/SEUNGJO/PythonDataScience


Information

Extracting essential data from a dataset and displaying it is a necessary part of data science; therefore individuals can make correct decisions based on the data. In this assignment, you will extract some essential economic indicators from some data, you will then display these economic indicators in a Dashboard. Gross domestic product (GDP) is a measure of the market value of all the final goods and services produced in a period. GDP is an indicator of how well the economy is doing. A drop in GDP indicates the economy is producing less; similarly an increase in GDP suggests the economy is performing better. In this lab, you will examine how changes in GDP impact the unemployment rate.

Define Function that Makes a Dashboard

We will import the following libraries.

import pandas as pd
from bokeh.plotting import figure, output_file, show,output_notebook
output_notebook()
def make_dashboard(x, gdp_change, unemployment, title, file_name):
    output_file(file_name)
    p = figure(title=title, x_axis_label='year', y_axis_label='%')
    p.line(x.squeeze(), gdp_change.squeeze(), color="firebrick", line_width=4, legend="% GDP change")
    p.line(x.squeeze(), unemployment.squeeze(), line_width=4, legend="% unemployed")
    show(p)
links={'GDP':'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_gdp.csv',\
       'unemployment':'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_unemployment.csv'}

Create a dataframe that contains the GDP data and display the first five rows of the dataframe.

Use the dictionary links and the function pd.read_csv to create a Pandas dataframes that contains the GDP data.

import pandas as pd
links={'GDP':'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_gdp.csv',\
       'unemployment':'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_unemployment.csv'}
df = pd.read_csv(links["GDP"])
import pandas as pd
links={'GDP':'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_gdp.csv',\
       'unemployment':'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_unemployment.csv'}
gdp_df = pd.read_csv(links["GDP"])
gdp_df.head()

Display a dataframe where unemployment was greater than 8.5%.

import pandas as pd
links={'GDP':'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_gdp.csv',\
       'unemployment':'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_unemployment.csv'}
df = pd.read_csv(links["unemployment"])
df["unemployment"] >= 0.085
df1=df[df["unemployment"] >= 0.085]
df1
0 True
1 True
2 True
3 True
4 True
5 True
6 True
7 True
8 True
9 True
10 True
11 True
12 True
13 True
14 True
15 True
16 True
17 True
18 True
19 True
20 True
21 True
22 True
23 True
24 True
25 True
26 True
27 True
28 True
29 True
...
39 True
40 True
41 True
42 True
43 True
44 True
45 True
46 True
47 True
48 True
49 True
50 True
51 True
52 True
53 True
54 True
55 True
56 True
57 True
58 True
59 True
60 True
61 True
62 True
63 True
64 True
65 True
66 True
67 True
68 True
Name: unemployment, Length: 69, dtype: bool

Use the function make_dashboard to make a dashboard

make_dashboard("dashboard")
x= df['date']
gdp_change = # Create your dataframe with column change-current
make_dashboard(gdp_change)
gdp_change=df['change-current']
unemployment= df['unemployment']
make_dashboard(new_dashboard)
new_dashboard = "title"
file_name = "index.html"

Originally published December 28, 2019
Latest update July 01, 2017

Related posts :