This file contains hidden or 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
def make_mean_variance(dataframe): | |
new_row = {} | |
for field in ['user', 'gender', 'age', 'how_tall_in_meters', 'weight', 'body_mass_index', 'class']: | |
new_row[field] = dataframe[field].iloc[0] | |
for field in ['roll1', 'pitch1', 'roll2', 'pitch2', 'roll3', 'pitch3','roll4', 'pitch4']: | |
new_row[field] = np.var(dataframe[field]) | |
for i in range (1, 5): |
This file contains hidden or 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 | |
contacts = pd.read_csv("contacts.csv") | |
contacts.drop_duplicates(subset=['Numero di telefono']) # name of the column that identifies the telephone number | |
# clears numbers that have more than 13 digits | |
index_to_drop = contacts[contacts['Numero di telefono'].map(len) != 13].index | |
contacts.drop(index_to_drop, inplace=True) |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct listas { | |
int info; | |
struct listas * next; | |
} list_t; | |
int listlen (list_t *); | |
list_t * listaddhead (list_t *, int); |
This file contains hidden or 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
# let's add information to our dataset | |
start_time <- Sys.time() | |
# function to transform angles deg into radians | |
deg2rad <- function(deg) {(deg * pi) / (180)} | |
if(!require(geosphere)){ | |
install.packages("geosphere") | |
library("geosphere") | |
} |
This file contains hidden or 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
# let's add information to our dataset | |
start_time <- Sys.time() | |
# function to transform angles deg into radians | |
deg2rad <- function(deg) {(deg * pi) / (180)} | |
if(!require(geosphere)){ | |
install.packages("geosphere") | |
library("geosphere") | |
} |
This file contains hidden or 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
# delete_duplicate_file.py | |
# Python 3.8.6 | |
""" | |
Given a folder, walk through all files within the folder and subfolders | |
and delete all file that are duplicates so you have only one copy of every file | |
The md5 checcksum for each file will determine the duplicates | |
""" | |
import os |
This file contains hidden or 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 logging | |
import logging.handlers | |
# Enable logging | |
logging.basicConfig( | |
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | |
level=logging.INFO, filename='log.log') | |
logger = logging.getLogger(__name__) |
This file contains hidden or 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
if(!require(corrplot)){ | |
install.packages("corrplot") | |
library("corrplot") | |
} | |
if(!require(RGraphics)){ | |
install.packages("RGraphics") | |
library("RGraphics") | |
} | |
if(!require(grid)){ | |
install.packages("grid") |
This file contains hidden or 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
# query to OpenStreetMap or bing to obtain information on the state, city, | |
# region both on the starting and ending point of each route | |
if(!require(revgeo)){ | |
install.packages("revgeo") | |
library("revgeo") | |
} | |
# I read the csv generated by the script compress_database.r |
This file contains hidden or 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 the n lines that identify me a path I get one line per path | |
# I load the csv that the add_feature_consistency.r script generated for me | |
perc_csv <- "dataset_with_add_features.csv" | |
dati <- read.csv(perc_csv, header = TRUE, sep =",", quote = "\"", dec = ".") | |
# we remove the file that generates this script | |
file.remove("dataset_compresso.csv") |