Skip to content

Instantly share code, notes, and snippets.

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=[]
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)]
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,
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)
@focaalvarez
focaalvarez / Create UK_map.py
Last active August 4, 2022 22:32
Plotly Example
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
(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;
};
#One liner to fill Nans
table1_fill_nans=table1.merge(table2,how='left',on='Person ID').fillna('Unknown')
# 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')
#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'],