Skip to content

Instantly share code, notes, and snippets.

View kururu-abdo's full-sized avatar
😍
Learning

kururu kururu-abdo

😍
Learning
View GitHub Profile
import numpy as np # useful for many scientific computing in Python
import pandas as pd #
#!pip3 install folium==0.5.0
import folium
print('Folium installed and imported!')
# define the world map
world_map = folium.Map()
from wordcloud import WordCloud, STOPWORDS
print ('Wordcloud imported!')
import urllib
# # open the file and read it into a variable alice_novel
alice_novel = urllib.request.urlopen('https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DV0101EN-SkillsNetwork/Data%20Files/alice_novel.txt').read().decode("utf-8")
stopwords = set(STOPWORDS)
def create_waffle_chart(categories, values, height, width, colormap, value_sign=''):
# compute the proportion of each category with respect to the total
total_values = sum(values)
category_proportions = [(float(value) / total_values) for value in values]
# compute the total number of tiles
total_num_tiles = width * height # total number of tiles
print ('Total number of tiles is', total_num_tiles)
# we can use the sum() method to get the total population per year
df_tot = pd.DataFrame(df_can[years].sum(axis=0))
# change the years to type int (useful for regression later on)
df_tot.index = map(int, df_tot.index)
# reset the index to put in back in as a column in the df_tot dataframe
df_tot.reset_index(inplace = True)
# rename columns
df_can.sort_values(['Total'], ascending=False, axis=0, inplace=True)
# get the top 5 entries
df_top5 = df_can.head()
# transpose the dataframe
df_top5 = df_top5[years].transpose()
df_top5.head()
import numpy as np # useful for many scientific computing in Python
import pandas as pd # primary data structure library
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
### type your answer here
df_CI = df_can.loc[['India', 'China'], years]
//drop columns
df.drop(['Unnamed: 0.1', 'Unnamed: 0'], axis=1, inplace=True)
//count sample or get dimensions
x_train_pr1.shape
import matplotlib.pyplot as plt
%matplotlib inline
#box plot // to show relation between
sns.boxplot(x="body-style", y="price", data=df)
#reg plot -- to show relation degree
sns.regplot(x="peak-rpm", y="price", data=df)
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
Input=[('scale',StandardScaler()),('model',LinearRegression())]
pipe=Pipeline(Input)
pipe.fit(df[['horsepower' ,'col1']],y)
ypipe=pipe.predict(df[['horsepower' ,'col1'])
def PlotPolly(model, independent_variable, dependent_variabble, Name):
x_new = np.linspace(15, 55, 100)
y_new = model(x_new)
plt.plot(independent_variable, dependent_variabble, '.', x_new, y_new, '-')
plt.title('Polynomial Fit with Matplotlib for Price ~ Length')
ax = plt.gca()
ax.set_facecolor((0.898, 0.898, 0.898))
fig = plt.gcf()
plt.xlabel(Name)