Skip to content

Instantly share code, notes, and snippets.

View jiobu1's full-sized avatar
💻
dreaming, learning, thinking

Jisha Obukwelu jiobu1

💻
dreaming, learning, thinking
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jiobu1 on github.
  • I am jiobu1 (https://keybase.io/jiobu1) on keybase.
  • I have a public key ASC04ebD2L2tRL6Wmi0GkQkrP5DIMVOABXyN2v2jG5oGEgo

To claim this, I am signing this object:

@jiobu1
jiobu1 / wrangle.py
Created March 3, 2021 16:11
Wrangle Function
def wrangle(X):
# Wrangle all df files to merge later
# Create copy
X = X.copy()
# Need this to create states column
k = X.iloc[0][0]
# Make sure that k has no extra characters
k = re.sub('[^a-zA-Z]', '', k)
@jiobu1
jiobu1 / qcut.py
Last active March 3, 2021 16:22
pd.qcut()
combined_csv['Crime Rating'] = pd.qcut(
combined_csv['Crime Rate (per 1000 residents)'],
q=3,
labels=['Low', 'Medium', 'High'])
@jiobu1
jiobu1 / pipe.py
Last active March 3, 2021 16:28
using .pipe()
pollution_df = pollution_df
.pipe(start_pipe)
.pipe(levels_of_concern)
.pipe(split_city_state)
.pipe(explode_str, col='City')
.pipe(explode_str, col='State')
.pipe(drop_columns)
@jiobu1
jiobu1 / nn.py
Last active April 26, 2021 00:43
Nearest Neigbor algorithm
# Nearest Neighbor
import numpy as np
from sklearn.neighbors import NearestNeighbors
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import make_pipeline
# Select columns that will be used to calculate nearest neighbors
X = merged[[
'TotalPop', 'Men', 'Women', 'Hispanic', 'White',
@jiobu1
jiobu1 / unique_combinations.py
Last active April 29, 2021 15:22
unique_school_combinations.py
print(df['Grades'].nunique())
df['Grades'].unique()
302
array(['9-12', '6-8', 'K-4', '5-8', '4-5', 'K-5', '4-6', '7-12', 'K-6','4-8', 'K-8', '1-6', 'PK-3', '6-12', 'K-3', 'PK-K', 'PK', 'PK-8',
'PK-6', '4-12', 'PK-6 & Ungraded', '1-8', 'K', 'PK-5', 'PK-12','7-11', '3-6', 'K-12', '3-8', '2-10', 'K-1, 5-8', 'PK-4',
'Ungraded', '1-12', '2-5', '3-5', '10-12', 'PK-1 & Ungraded','K-11', 'K-2', 'K-1', '9-10', 'K-7', '1-5', 'PK-1', 'PK-K, 2',
'PK-2', '7-8', 'PK-11', '9', 'K-9', '2-11', '2-12', '2-9', '8-12','K-10', 'PK & Ungraded', '7-9', '6', '5-6', '2, 5-6, 8-9, 11-12',
'11-12', '3-12', 'K-1, 3-4, 6-7, 9, 11', '1-11', '5-12', '6-10','11', '3-7', '7-10', 'PK-10', 'PK-12 & Ungraded', 'PK-9', '6-9',
'4-9', '9-11', '6-7', '5-12 & Ungraded', '8-11', '2-8', '3, 5, 7-11', 'PK, 8', 'PK-7', '6, 9-12', '1-3', 'K-3, 5-10, 12',
@jiobu1
jiobu1 / test_driven_function.py
Last active April 23, 2021 19:27
creating tests
import unittest
class TestParseGrades(unittest.TestCase):
def test_join_string_grades_success(self):
actual = parse_grades('2, 4, 6, 8, 10, 12')
expected = ['2','4','6','8','10','12']
self.assertEqual(actual, expected)
def test_parse_grades_success(self):
actual = parse_grades('K-4')
@jiobu1
jiobu1 / separating_process.py
Created April 23, 2021 19:24
final function
# Parse combineed grades
def parse_grades(grades_string):
GRADES = ['PK', 'K', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', 'Ungraded']
# Remove & for grades list
grades_string = grades_string.replace(' &', ',')
# Grades list - will add to separated grade string to grades
grades = []
def parse_grades(grades_string):
GRADES = ['PK', 'K', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', 'Ungraded']
# Remove & for grades list
grades_string = grades_string.replace(' &', ',')
# Grades list - will add to separated grade string to grades
grades = []
# split strings based on ','
@jiobu1
jiobu1 / beautfiul_soup.py
Last active April 26, 2021 00:31
first attempt using beautiful soup
import requests
from bs4 import BeautifulSoup
url = "https://www.greatschools.org/new-york/new-york/schools/?tableView=Overview&view=table"
page_response = requests.get(url)
content = BeautifulSoup(page_response.text,"html.parser")
table=content.find_all('table')
table