Skip to content

Instantly share code, notes, and snippets.

View mamadyonline's full-sized avatar

Mamady mamadyonline

  • Grenoble, France
View GitHub Profile
"""Test data base module"""
import unittest
from data_engineering.database.fake_players import generate_fake_player
from data_engineering.database.players import Player
from data_engineering.database.postgres_db import DataBase
class TestDB(unittest.TestCase):
def setUp(self) -> None:
@mamadyonline
mamadyonline / fake_players.py
Last active June 10, 2019 23:25
Generate fake football players
from faker import Faker
import random
COUNTRIES = ['Argentina', 'Portugal', 'France', 'Brazil',
'England', 'Belgium', 'Italy', 'Spain', 'Germany',
'Ivory coast', 'Guinea', 'Senegal', 'Ghana',
'Nigeria', 'Cameroun', 'Egypt', 'Morocco', 'Algeria',
'USA', 'Croatia', 'Sweden', 'Columbia', 'Netherlands',
'Danemark', 'Ireland', 'Switzerland']
@mamadyonline
mamadyonline / database_operations.py
Last active June 10, 2019 22:54
Queries on the Postgres database
"""Class defining some queries for the database via SQLAlchemy"""
from typing import List
from data_engineering.database.base import Base, Session, data_base
from data_engineering.database.players import Player
class DataBase:
def __init__(self):
"""Create players class and define its characteristics"""
from data_engineering.database.base import Base
from sqlalchemy import String, Integer, Column, Boolean
class Player(Base):
__tablename__ = 'players'
id = Column(Integer, primary_key=True)
@mamadyonline
mamadyonline / base_definitions.py
Last active June 10, 2019 23:26
Base definitions for SQLAlchemy configuration
"""This code creates:
* a SQLAlchemy Engine that will interact with our dockerized PostgreSQL database,
* a SQLAlchemy ORM session factory bound to this engine,
* a base class for our classes definitions.
"""
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
@mamadyonline
mamadyonline / decimal.py
Created December 21, 2018 17:55
Decimals in Python
from decimal import Decimal
# We can construct decimal numbers with integers, floats and strings
# Using integers and floats return the exact representation of the
# as stored by Python, on 64 bits
a = Decimal(0.1) # Decimal('0.1000000000000000055511151231257827021181583404541015625')
b = Decimal('0.1') # Decimal('0.1')
# It also works with NaN and Infinity
decimal_nan = Decimal('NaN')
@mamadyonline
mamadyonline / outlier_detection.ipynb
Last active November 25, 2018 21:27
Outlier detection algorithms applied to a univariate time series data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mamadyonline
mamadyonline / pso.py
Last active April 15, 2019 20:43
Python PSO implementation.
import numpy as np
class PSO(object):
"""
Class implementing PSO algorithm.
"""
def __init__(self, func, init_pos, n_particles):
"""
Initialize the key variables.