World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Import the boston housing dataset, but while importing change the 'medv' (median house value) column so that values < 35 becomes ‘Low’ and > 35 becomes ‘High’.
import csv with open('BostonHousing.csv', 'r') as f: reader = csv.reader(f) out = [] for i, row in enumerate(reader): if i > 0: row[13] = 'High' if float(row[13]) > 35 else 'Low' out.append(row) df = pd.DataFrame(out[1:], columns=out[0]) print(df.head())