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:
I hereby claim:
To claim this, I am signing this object:
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) |
combined_csv['Crime Rating'] = pd.qcut( | |
combined_csv['Crime Rate (per 1000 residents)'], | |
q=3, | |
labels=['Low', 'Medium', 'High']) |
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) |
# 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', |
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', |
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') |
# 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 ',' |
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 |