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 math | |
def Wallis_Pi(n): | |
''' | |
Compute the decimals of Pi using the Wallis formula: | |
''' | |
return 2*math.prod([4*i**2 / (4*i**2 - 1) for i in range(1, n + 1)]) | |
Wallis_Pi(100_000) |
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 math import radians, sin, cos, atan2, sqrt, tan, atan | |
def haversine_distance(long1, lat1, long2, lat2, degrees=False): | |
''' | |
The haversine formula determines the great-circle distance | |
between two points on a sphere given their longitudes and latitudes. | |
''' | |
#degrees vs radians | |
if degrees == True: | |
long1 = radians(long1) |
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 sklearn.preprocessing import LabelEncoder | |
class MultiColumnLabelEncoder: | |
''' | |
modified the scripts of Daria Vasyukova | |
''' | |
def __init__(self, X): | |
self.X = 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
# Define function to detect outliers for numerical variables | |
import pandas as pd | |
def clean_outliers(data, types = "IQR", threshold = 3.0): | |
''' | |
This function will cleanse outliers only | |
and leave missing values alone. | |
Parameters: | |
data (DataFrame): Raw data that need to detect and clean the outliers. |
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
''' | |
This file is used to loop through sub-directories | |
and copy multiple files with a specific filename, | |
then rename them in a new folder. | |
''' | |
import os, shutil, re | |
def main(): | |
src = "/media/Folder From" |