# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Exploring Data in Jupyter Notebook

# Importing the data 

import pandas
df = pandas.read_excel('house_price.xlsx')
df[:10]

# A quick look of the data...

df.describe()

# We can also create histograms to see the distributions of our data...

df.hist(figsize=(20,20))

# Or we can also create scatter plots to see the relationships among all columns..

from  pandas.plotting import scatter_matrix
scatter_matrix(df,figsize=(20, 20), diagonal='kde')

# # Exploring the data.. we want to see how many different types of houses are in the record:

df.groupby('house_type').count()

# Let's compare the average prices and views for each type of houses.

df.groupby('house_type').mean()

# We can also visualize the difference by creating histograms for each type of houses.

df.groupby('house_type').hist(figsize=(12,4),column=['price','views'])

# Or if we want to see how the ages of houses determine the prices. Here we use a scatterplot.

df.plot.scatter(x='built_in',y='price')

# Since house prices are largely determined by sizes, ages and other factors, let's see how the house ages determine the house unite price, i.e., price/size. Let's calculate the unit price first, and then add the results to a new column called unit_price

df['unit_price']=df['price']/df['area']

# For each year, we calculate the average unite price, and assign the result to a new dataframe

mean_price =df.groupby('built_in').mean()

# A Line chart is a good choice for visualizing trends. Let's use a line chart to see how the unite prices is determined by the house ages.

mean_price.plot.line(y='unit_price')

# This is how we visualize and read files in Jupyter Notebook with Excel. 

StarcoderdataJupyterScriptsDedupFiltered