目前在kaggle学习,读取处理文件一般用的是pandas,记录一下卡住我很久的点。
我了解到的有2种方式:
# What is the average lot size (rounded to nearest integer)?
avg_lot_size = round(home_data['LotArea'].mean())
# As of today, how old is the newest home (current year - the date in which it was built)
newest_home_age = round(2020 - home_data.YearBuilt.max())
# Checks your answers
step_2.check()
第一种是:home_data['LotArea'].mean()
第二种是:home_data.YearBuilt.max()
注意:LotArea、YearBuilt均为home_data的属性;而mean、max方法为取均值、最大值
记录一下,以供参考。