Skip to content

DM for Business Analytics Ch1&2_WestRoxbury

import pandas as pd

housing_df = pd.read_csv('WestRoxbury.csv')
housing_df.shape
housing_df.head()
print(housing_df)
housing_df.columns
housing_df = housing_df.rename(columns={'TOTAL VALUE': 'TOTAL_VALUE'})
housing_df.columns = [s.strip().replace(' ', '_') for s in housing_df.columns]
housing_df.columns
housing_df.loc[0:3]
housing_df.iloc[0:4]
housing_df['TOTAL_VALUE'].iloc[0:10]
housing_df.iloc[0:10]['TOTAL_VALUE']
housing_df.iloc[0:10].TOTAL_VALUE
housing_df.iloc[4][0:10]
housing_df.iloc[4, 0:10]
housing_df.iloc[4:5, 0:10]
#Concatenation (axis = 1 means the concatenation glues the columns together)
pd.concat([housing_df.iloc[4:6,0:2], housing_df.iloc[4:6,4:6]], axis=1)
#Concatenation (axis = 0 means that concatenation glues the rows together)
pd.concat([housing_df.iloc[4:6,0:2], housing_df.iloc[4:6,4:6]], axis=0)
housing_df.iloc[:,0:1]
housing_df.TOTAL_VALUE
housing_df['TOTAL_VALUE'][0:10]
print('Number of rows ', len(housing_df['TOTAL_VALUE']))
print('Mean of TOTAL_VALUE ', housing_df['TOTAL_VALUE'].mean())
housing_df.describe()