import sys
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import random as rd
print('Python: {}'.format(sys.version))
print('pandas: {}'.format(pd.__version__))
print('numpy: {}'.format(np.__version__))
print('matplotlib {}'.format(matplotlib.__version__))
df = pd.read_csv('Sacramentorealestatetransactions.csv')
print(df.head(10))
print(df.describe())
df_NumData = df[['beds','baths','sq__ft','price']]
print(df_NumData.describe())
df['price'].hist(bins=100)
plt.show()
df.boxplot(column='price')
plt.show()
df.boxplot(column='price', by = 'beds')
plt.show()
df[['price','beds']].groupby('beds').boxplot()
plt.show()
bedcount = df['beds'].value_counts()
print(bedcount)
bedcount = df['beds'].value_counts(ascending=True)
print(bedcount)
print(bedcount.sort_index(axis=0,ascending=True))
print(bedcount.sort_index(axis=0,ascending=False))
print(bedcount.sort_values(axis=0))
avgPricePivot = df.pivot_table(values='price',index=['beds'],aggfunc=lambda x: x.mean())
print(avgPricePivot)
avgPricePivot = df.pivot_table(values='price',index=['beds'],aggfunc=lambda x: [x.mean(),x.min(), x.max()])
print(avgPricePivot)
pd.plotting.scatter_matrix(df_NumData)
plt.show()