This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.plotly as py | |
import plotly.graph_objs as go | |
hover_text = [] | |
color_range = [] | |
for index, row in bcg_matrix.iterrows(): | |
hover_text.append(('Borough: {borough}<br>'+ | |
'Neighborhood: {neighborhood}<br>'+ | |
'Share: {share}%<br>'+ | |
'Growth: {growth}%<br>'+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# generate battleship board and solution | |
def new_board(): | |
# create a clear board | |
dim = 10 | |
board = np.zeros((dim, dim), dtype=int) | |
# randomly place ships on the board |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# calculates the content-based product similarity matrix | |
# items is a Pandas dataframe containing all product details available for comparison | |
# returns the feature matrix and the correlation matrix | |
def product_similarity(items): | |
# drop multicollinear columns and columns not considered for similarity | |
items = items.drop(['Item', 'Style', 'Product', 'On Sale'], axis=1) | |
print(items.nunique()) |