From f2af8e8eddb5945a70c1fde5fcf3c481154ec919 Mon Sep 17 00:00:00 2001
From: Sal2912 <58745060+Sal2912@users.noreply.github.com>
Date: Tue, 3 Mar 2020 00:02:03 -0500
Subject: [PATCH 1/6] Delete first_last_name_reverse.py
---
first_last_name_reverse.py | 4 ----
1 file changed, 4 deletions(-)
delete mode 100644 first_last_name_reverse.py
diff --git a/first_last_name_reverse.py b/first_last_name_reverse.py
deleted file mode 100644
index 50bfa31..0000000
--- a/first_last_name_reverse.py
+++ /dev/null
@@ -1,4 +0,0 @@
-first_name = input("Enter your First Name: ")
-last_name = input("Enter your Last Name: ")
-full_name = first_name + last_name
-print(f'Reversed name is: {full_name[: :-1]}')
From 567386b1d0d1475a4f7916712f7dac4179661d10 Mon Sep 17 00:00:00 2001
From: Sal2912 <58745060+Sal2912@users.noreply.github.com>
Date: Tue, 3 Mar 2020 00:02:30 -0500
Subject: [PATCH 2/6] Add files via upload
Python file
---
US Economic data .py | 329 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 329 insertions(+)
create mode 100644 US Economic data .py
diff --git a/US Economic data .py b/US Economic data .py
new file mode 100644
index 0000000..dd748a3
--- /dev/null
+++ b/US Economic data .py
@@ -0,0 +1,329 @@
+#!/usr/bin/env python
+# coding: utf-8
+
+#
+
+#
+# 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. You will take screen shots of every step, you will share the notebook and the URL pointing to the dashboard.
+ +#+# Estimated Time Needed: 180 min
+#make_dashboard
.
+# You don't have to know how the function works, you should only care about the inputs. The function will produce a dashboard as well as an html file. You can then use this html file to share your dashboard. If you do not know what an html file is don't worry everything you need to know will be provided in the lab.
+
+# In[2]:
+
+
+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)
+
+
+# The dictionary links
contain the CSV files with all the data. The value for the key GDP
is the file that contains the GDP data. The value for the key unemployment
contains the unemployment data.
+
+# In[3]:
+
+
+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'}
+
+
+# links
and the function pd.read_csv
to create a Pandas dataframes that contains the GDP data.
+
+# Hint: links["GDP"]
contains the path or name of the file.
+
+# In[6]:
+
+
+# Type your code here
+df_GDP = pd.read_csv(links['GDP'])
+df_GDP
+
+
+# Use the method head()
to display the first five rows of the GDP data, then take a screen-shot.
+
+# In[7]:
+
+
+# Type your code here
+df_GDP.head()
+
+
+# links
and the function pd.read_csv
to create a Pandas dataframes that contains the unemployment data.
+
+# In[8]:
+
+
+# Type your code here
+df_Unemployment = pd.read_csv(links['unemployment'])
+
+
+# Use the method head()
to display the first five rows of the GDP data, then take a screen-shot.
+
+# In[9]:
+
+
+# Type your code here
+df_Unemployment.head()
+
+
+# make_dashboard
, to produce a dashboard. We will use the convention of giving each variable the same name as the function parameter.
+
+# Create a new dataframe with the column 'date'
called x
from the dataframe that contains the GDP data.
+
+# In[17]:
+
+
+x = df_GDP['date']
+x
+
+
+# Create a new dataframe with the column 'change-current'
called gdp_change
from the dataframe that contains the GDP data.
+
+# In[18]:
+
+
+gdp_change = df_GDP['change-current']
+gdp_change
+
+
+# Create a new dataframe with the column 'unemployment'
called unemployment
from the dataframe that contains the unemployment data.
+
+# In[19]:
+
+
+unemployment = df_Unemployment['unemployment']
+unemployment
+
+
+# Give your dashboard a string title, and assign it to the variable title
+
+# In[21]:
+
+
+title = 'US Economic Data Analysis'
+title
+
+
+# Finally, the function make_dashboard
will output an .html
in your direictory, just like a csv
file. The name of the file is "index.html"
and it will be stored in the varable file_name
.
+
+# In[22]:
+
+
+file_name = "index.html"
+
+
+# Call the function make_dashboard
, to produce a dashboard. Assign the parameter values accordingly take a the , take a screen shot of the dashboard and submit it.
+
+# In[23]:
+
+
+# Fill up the parameters in the following function:
+make_dashboard(x=x, gdp_change=gdp_change, unemployment=unemployment, title=title, file_name=file_name)
+
+
+# access_key_id
and secret_access_key
. Do not delete # @hidden_cell
as this will not allow people to see your credentials when you share your notebook.
+
+#
+# credentials = {
+# "apikey": "your-api-key",
+# "cos_hmac_keys": {
+# "access_key_id": "your-access-key-here",
+# "secret_access_key": "your-secret-access-key-here"
+# },
+#
+#
+# "endpoints": "your-endpoints",
+# "iam_apikey_description": "your-iam_apikey_description",
+# "iam_apikey_name": "your-iam_apikey_name",
+# "iam_role_crn": "your-iam_apikey_name",
+# "iam_serviceid_crn": "your-iam_serviceid_crn",
+# "resource_instance_id": "your-resource_instance_id"
+# }
+#
+
+# In[ ]:
+
+
+# @hidden_cell
+#
+
+
+# You will need the endpoint make sure the setting are the same as PROVISIONING AN OBJECT STORAGE INSTANCE ON IBM CLOUD assign the name of your bucket to the variable bucket_name
+
+# In[ ]:
+
+
+endpoint = 'https://s3-api.us-geo.objectstorage.softlayer.net'
+
+
+# From the tutorial PROVISIONING AN OBJECT STORAGE INSTANCE ON IBM CLOUD assign the name of your bucket to the variable bucket_name
+
+# In[ ]:
+
+
+bucket_name = # Type your bucket name on IBM Cloud
+
+
+# We can access IBM Cloud Object Storage with Python useing the boto3
library, which we’ll import below:
+
+# In[ ]:
+
+
+import boto3
+
+
+# We can interact with IBM Cloud Object Storage through a boto3
resource object.
+
+# In[ ]:
+
+
+resource = boto3.resource(
+ 's3',
+ aws_access_key_id = credentials["cos_hmac_keys"]['access_key_id'],
+ aws_secret_access_key = credentials["cos_hmac_keys"]["secret_access_key"],
+ endpoint_url = endpoint,
+)
+
+
+# We are going to use open
to create a file object. To get the path of the file, you are going to concatenate the name of the file stored in the variable file_name
. The directory stored in the variable directory using the +
operator and assign it to the variable
+# html_path
. We will use the function getcwd()
to find current the working directory.
+
+# In[ ]:
+
+
+import os
+
+directory = os.getcwd()
+html_path = directory + "/" + file_name
+
+
+# Now you must read the html file, use the function f = open(html_path, mode)
to create a file object and assign it to the variable f
. The parameter file
should be the variable html_path
, the mode should be "r"
for read.
+
+# In[ ]:
+
+
+# Type your code here
+
+
+# To load your dataset into the bucket we will use the method put_object
, you must set the parameter name to the name of the bucket, the parameter Key
should be the name of the HTML file and the value for the parameter Body should be set to f.read()
.
+
+# In[ ]:
+
+
+# Fill up the parameters in the following function:
+# resource.Bucket(name=).put_object(Key=, Body=)
+
+
+# In the dictionary Params
provide the bucket name as the value for the key 'Bucket'. Also for the value of the key 'Key' add the name of the html
file, both values should be strings.
+
+# In[ ]:
+
+
+# Fill in the value for each key
+# Params = {'Bucket': ,'Key': }
+
+
+# The following lines of code will generate a URL to share your dashboard. The URL only last seven days, but don't worry you will get full marks if the URL is visible in your notebook.
+
+# In[ ]:
+
+
+import sys
+time = 7*24*60**2
+client = boto3.client(
+ 's3',
+ aws_access_key_id = credentials["cos_hmac_keys"]['access_key_id'],
+ aws_secret_access_key = credentials["cos_hmac_keys"]["secret_access_key"],
+ endpoint_url=endpoint,
+
+)
+url = client.generate_presigned_url('get_object',Params=Params,ExpiresIn=time)
+print(url)
+
+
+# Once you complete your notebook you will have to share it to be marked. Select the icon on the top right a marked in red in the image below, a dialogue box should open, select the option all content excluding sensitive code cells.
+# +#You can then share the notebook via a URL by scrolling down as shown in the following image:
+#
Copyright © 2019 IBM Developer Skills Network. This notebook and its source code are released under the terms of the MIT License.
+ +#+# Other contributors: Yi leng Yao, Mavis Zhou +#
+ +#
+#
D1sO@844y@>&OD{!sWZ!q-|FqwA;5*t!>D3n)EzA;$^UGD#Y1_v4iOh6tX_js%#
zz+ZoVPpzAM&zlRw^#V!-@y*yc3l^0lvO1kHz1%RJ;aX#w1L~=*h;IBL+b_8D*t>?e
z9q?1^`Q;fg>9rNWqlR)Y%z5_4{~~EEfV3&>K}Hp(xW_a=M~Rvz3mhzEE~UCPgu^9+
z1Mv+*7T&!}$ous@PGvmlK_JcMt#MBzl|XuZ6 7*;yL0xthAO!
zbyFe@pf}nAyC(5T=DVkrSIVXu+BcE#$~Os9T3M%oTWzzm47*B>Y-%%UFa2I-bTYB9
zpy|xa0{eqNA=&|3o416