<jupyter_start><jupyter_text>Homework 3  - Tryout pandas and numpyCopy this notebook. Rename it as: YOURNAME-Homework-panda-numpy-Sept-2017with your name replacing yourname and  replaced with the date you submit or to the last part.Do the homeworks problems below.Upload your completed jupyter notebook to your github site and send me the url via the elearning site as your homework submission. Please note that you need to do your own 3.4, and 3.5 if you share data and analysis from others then you cannot get more than a 3.    Homework 3.1 3.1.aLoad the data from: http://opendata.dc.gov/datasets that I have include in this github   into a dataframe.  ( The file has been is available in directory ./data/ccp_current_csv.csv )<jupyter_code>import pandas as pd
import numpy as np

hw = pd.read_csv("data/ccp_current_csv.csv")
hw<jupyter_output><empty_output><jupyter_text>3.1.a  what is its shape and what does that mean?<jupyter_code>hw.shape
# This dataset has 465 rows and 27 columns.<jupyter_output><empty_output><jupyter_text>Homework 3.2 What are the number of rows in each 'QUADRANT' ?<jupyter_code>pd.Series(hw.QUADRANT).value_counts()<jupyter_output><empty_output><jupyter_text>Homework 3.3 - Array math demonstration For two arrarys  a= [1,2,3,4]  type=floatb= [5,6,7,8]  type=floatPeform the following array operations using numpy   ( show both operational use of numpy and functional (example addition operation => + vs addition function => numbpy.add() ) 3.3.1 addition a+b<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt

from numpy import *

A = array([1,2,3,4], dtype = float)
B = array([5,6,7,8], dtype = float)
# use + operator
A + B 
# use add function
np.add(A,B)<jupyter_output><empty_output><jupyter_text>3.3.2 subtraction a-b<jupyter_code># use - operator
A - B
# use subtract function
np.subtract(A,B)<jupyter_output><empty_output><jupyter_text>3.3.3 multiplication a*b<jupyter_code># use * operator
A * B
# use multiply function
np.multiply(A,B)<jupyter_output><empty_output><jupyter_text>3.3.4 divsion a/b<jupyter_code># use / operator
A / B
# use divide function
np.divide(A,B)<jupyter_output><empty_output><jupyter_text>3.3.5 modulo  a%b<jupyter_code># use % operator
A % B
# use fmod function
np.fmod(A,B)<jupyter_output><empty_output><jupyter_text>3.3.6 power  a^b<jupyter_code># use ** operator
A ** B
# use power function
np.power(A,B)<jupyter_output><empty_output><jupyter_text>Homework 3.4Find your own data and load it into a dataframe<jupyter_code>%matplotlib inline
import pandas as pd
import numpy as np

# Company executives from a large packaged foods manufacturer wished to determine which factors influence the market share of one of its products. Data were collected from a national database (Nielsen) for 36 consecutive months.
# market share : Average monthly market share for product (percent)
# price : Average monthly price of product (dollars)
# discount price : Presence or absence of discount price during, period: 1 if discount, 0 otherwise
# package promotion : Presence or absence of package promotion during, period: 1 if promotion present, 0 otherwise
mb = pd.read_excel('data/dataset.xlsx')
mb<jupyter_output><empty_output><jupyter_text>Homework 3.5Provide an interesting analysis of the data columns ( frequency or averages )<jupyter_code># A useful summarization that gives a quick snapshot of multiple statistics for "price"
mb.price.describe()
# correlation between all columns
mb.corr()
# mean of each columns
mb.mean()
# sum of each columns
mb.sum()
# count how many rows in each month
pd.Series(mb.month).value_counts()
# count how many rows in each year
pd.Series(mb.year).value_counts()
# the most difference between all the price
mb1 = mb[['price']]
price_range = lambda price: mb.price.max() - mb.price.min()
mb1.apply(price_range)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09303534303534304, 'fraction_numerical': 0.018451143451143452, 'mean_word_length': 5.46890756302521, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '402013', 'license': 'MIT', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1252, 'n_words': 432, 'path': 'Yiran Yu-Homework-panda-numpy-Sept-2018.ipynb', 'repo_name': 'yyr0717/big-data-python-class', 'size': '3848'}