Skip to content

Instantly share code, notes, and snippets.

View yfujieda's full-sized avatar

Yuki yfujieda

View GitHub Profile
#!usr/local/bin/python3
import operator
import pandas as pd
import numpy as np
from scipy import spatial
def ComputeDistance(a, b):
dataA = a[1]
dataB = b[1]
"""
module to convert the strings to either lowercase or uppercase
"""
def to_lowercase(given_strings):
""""convert given strings to lower case"""
return given_strings.lower()
def to_uppercase(given_strings):
""""convert given strings to upper case"""
"""crud module"""
import pymysql.cursors
def connection():
"""
function to establish connection with the database
"""
SERVER_URL = "localhost"
"""crud module"""
import pymysql.cursors
def connection():
"""
function to establish connection with the database
"""
SERVER_URL = "localhost"
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
# Use a service account
cred = credentials.Certificate('serviceAccountKey.json')
firebase_admin.initialize_app(cred)
db = firestore.client()
from docx import Document
time_and_date = "2019-10-21"
employee_name = "John Smith"
manager_name = "Michelle Johnson"
department_name = "HR Department"
save_filename = employee_name + "_recognition_letter_drafted.docx"
document = Document('recognition_letter_template.docx')
#!/usr/local/bin/python3
import operator
import pandas as pd
import numpy as np
from scipy import spatial
r_cols = ['user_id', 'movie_id', 'rating']
ratings = pd.read_csv('ml-100k/u.data', sep='\t', names=r_cols, usecols=range(3))
@yfujieda
yfujieda / python-dask-example.py
Last active October 3, 2019 18:06
python-dask-example
# using dask to handle the big dataset
import dask.dataframe as dd
# use numpy to conver the dask dataframe object to array object
import numpy as np
# load the dataset file
file_name = 'sample_data_set.csv'
#row_count to output
@yfujieda
yfujieda / data-export-csv.py
Created October 2, 2019 21:55
Export data to CSV file
import os
import random
r_size = int(10) # set the number of times you want to iterate
file_name = "sample_output_to_csv.csv" # file name to be used when saving as CSV file
# file_string value below will be stored as the first line in the CSV file
# first line is usually the header row
file_string = "UID,NUM_VALUE,NOTES\n"
def foo():
a = 'test'
return a