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 requests | |
import pandas as pd | |
from bs4 import BeautifulSoup | |
from PIL import Image | |
#Scrapping images and extracting color | |
website = "https://masglo.com/product-category/esmaltes/" | |
product_images=[] |
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 | |
import networkx as nx | |
import netwulf as wulf | |
import community as community_louvain | |
df = pd.read_csv('YOUR RELATIONS FILE.csv') | |
#Filter the user following accounts to a smaller subset of accounts that follow me | |
df=df[df['following'].isin(my_followers)] |
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
from instapy import InstaPy | |
from instapy import smart_run | |
import pandas as pd | |
# login credentials | |
insta_username = #your user name | |
insta_password = #your password | |
# get an InstaPy session! | |
session = InstaPy(username=insta_username, |
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 | |
import json | |
from urllib.request import urlopen | |
import numpy as np | |
#Load GeoJson | |
with urlopen('https://opendata.arcgis.com/datasets/48b6b85bb7ea43699ee85f4ecd12fd36_4.geojson') as response: | |
counties = json.load(response) | |
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 | |
import json | |
from urllib.request import urlopen | |
import numpy as np | |
#Load GeoJson | |
with urlopen('https://opendata.arcgis.com/datasets/48b6b85bb7ea43699ee85f4ecd12fd36_4.geojson') as response: | |
counties = json.load(response) | |
#Load data to be charted |
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
(function (global, factory) { | |
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-drag'), require('d3-interpolate'), require('d3-selection'), require('d3-transition')) : | |
typeof define === 'function' && define.amd ? define(['exports', 'd3-dispatch', 'd3-drag', 'd3-interpolate', 'd3-selection', 'd3-transition'], factory) : | |
(factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3,global.d3)); | |
}(this, (function (exports,d3Dispatch,d3Drag,d3Interpolate,d3Selection,d3Transition) { 'use strict'; | |
var constant = function(x) { | |
return function() { | |
return x; | |
}; |
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 | |
from pytrends.request import TrendReq | |
pytrend = TrendReq() | |
#for multiple keywords in English | |
list_of_keywords=['champagne','cognac','wine','whisky','vodka'] | |
#for multiple countries | |
list_of_regions=['AT', 'BE', 'BG', 'DE', 'DK', 'EE', 'GB', 'GR', 'HU', 'HR'] |
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
#One liner to fill Nans | |
table1_fill_nans=table1.merge(table2,how='left',on='Person ID').fillna('Unknown') |
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
# Add only 1 column (City) | |
table1_city=table1.merge(table2[['Person ID','City']],how='left',on='Person ID') | |
#Add all columns of table 2 (City and language) | |
table1_all=table1.merge(table2,how='left',on='Person ID') |
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
#Train Models and get score | |
train_scores=[] | |
test_scores=[] | |
for model in model_list: | |
model.fit(X_train, y_train) | |
train_scores.append(model.score(X_train, y_train)) | |
test_scores.append(model.score(X_test, y_test)) | |
scores_df= pd.DataFrame( | |
{'Model Name': ['tree','logreg','knn','naive_b','forest','gbrt','mlp','svc'], |
NewerOlder