Study on Tokyo Rent Using Python (3-3)

Result excerpt

Simultaneous posting on the blog: https://leoluistudio.com/blog/42/python%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e6%9d%b1%e4%ba%ac%e9%83%bd%e5%ae%b6%e8%b3%83%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6%e3%81%ae%e7%a0%94%e7%a9%b6-4%e3%81%ae3/


Statistical method 2

Programs and results

Calculate median for each building

The reason is that the number of properties in the building is different. For example, if you have 50 properties per building, the weight will be 50 times that of 1 property per building when you calculate the distribution. Take the median for each building so that it is calculated evenly.

conn = sqlite3.connect(‘info.db’)
df = pd.read_sql_query(“SELECT pid,price,area FROM price”, conn)
conn.close()

df[‘municipal’] = df.apply(municipal, axis=1)
dfmedian = df.groupby([‘pid’, ‘municipal’])[‘price’, ‘area’, ‘average’].median()
dfmedian_reset = dfmedian.reset_index(level=’municipal’)

Price distribution by ward (23 wards)

#Graph
fig = go.Figure()
for i in m23_list:
    dfgroup = dfmedian_reset[dfmedian_reset[‘municipal’] == i]
    fig.add_trace(go.Box(x=dfgroup[‘price’], y=dfgroup[‘municipal’], boxpoints=False))
fig.update_traces(orientation=’h’, showlegend=False)
fig.update_xaxes(range=[0, 500000])

L2no2A.png


Area distribution for each ward (23 wards)

#Graph
fig = go.Figure()
for i in m23_list:
    dfgroup = dfmedian_reset[dfmedian_reset[‘municipal’] == i]
    fig.add_trace(go.Box(x=dfgroup[‘area’], y=dfgroup[‘municipal’], boxpoints=False))
fig.update_traces(orientation=’h’, showlegend=False)
fig.update_xaxes(range=[0, 100])

L2no2B.png


Calculate the average price (price / area)

def average(df):
    return int(df[‘price’] / df[‘area’])

df[‘average’] = df.apply(average, axis=1)

Distribution of average price for each ward (23 wards)

#Graph
fig = go.Figure()
for i in m23_list:
    dfgroup = dfmedian_reset[dfmedian_reset[‘municipal’] == i]
    fig.add_trace(go.Box(x=dfgroup[‘average’], y=dfgroup[‘municipal’], boxpoints=False))
fig.update_traces(orientation=’h’, showlegend=False)

L2no2D.png


Relationship between average price and walking time to the station

#Dataframe processing
dfmedian_reset = dfmedian.reset_index(level=’pid’)
dfmedian_reset[‘train’] = dfmedian_reset.apply(trainminute, axis=1)

#Graph
fig = px.scatter(dfmedian_reset, x=’train’, y=’average’, height=500, width=1000)

L2no3.png


Relationship between average price and building type

dfmedian_reset = dfmedian.reset_index(level=’pid’)
dfmedian_reset[‘type’] = dfmedian_reset.apply(buildtype, axis=1)
fig = go.Figure()
for i in (['apartment',‘Apartment’]):
    dfgroup = dfmedian_reset[dfmedian_reset[‘type’] == i]
    fig.add_trace(go.Box(x=dfgroup[‘price’], y=dfgroup[‘type’], boxpoints=False))
fig.update_traces(orientation=’h’, showlegend=False)
fig.update_xaxes(range=[0, 500000])
fig.update_layout(height=500, width=1000)

L2no4.png


Other results

Relationship between average price and building type L2no5.png


Relationship between average price and building structure L2no6.png


Relationship between average price and parking lot L2no7.png


Relationship between average price and parking lot L2no8.png


Distribution of completion dates (divided into 23 wards and city areas) L2no9.png


Direction and price heatmap for municipalities L3no1.png

Recommended Posts

Study on Tokyo Rent Using Python (3-2)
Study on Tokyo Rent Using Python (3-3)
Study on Tokyo Rent Using Python (3-1 of 3)
Broadcast on LINE using python
Notes on using MeCab from Python
Preparing python using vscode on ubuntu
Notes on installing Python using PyEnv
Notes on using rstrip with python.
Install Python on CentOS using Pyenv
Install Python on CentOS using pyenv
Notes for using OpenCV on Windows10 Python 3.8.3.
Execute Python code on C ++ (using Boost.Python)
Detect "brightness" using python on Raspberry Pi 3!
Install python library on Lambda using [/ tmp]
Map rent information on a map with python
Run servomotor on Raspberry Pi 3 using python
Detect temperature using python on Raspberry Pi 3!
Video processing using Python + OpenCV on Mac
Notes on using code formatter in Python
Python study note_002
Python study notes _000
Python on Windows
twitter on python3
Python study note_004
Start using Python
python on mac
Python study note_003
Python study notes _005
Python on Windbg
Scraping using Python
Python study notes_001
Python study day 1
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Notes on installing Python3 and using pip on Windows7
Install Python 3.8.6 on macOS Big Sur using pyenv
Python: Try using the UI on Pythonista 3 on iPad
Python development on Ubuntu on AWS EC2 (using JupyterLab)
Detect magnet switches using python on Raspberry Pi 3!
Notes on using dict in python [Competition Pro]
Sound the buzzer using python on Raspberry Pi 3!
Generate points only in Tokyo using python + shapely
[Python] Notes on accelerating genetic algorithms using multiprocessing
Initial settings for using Python3.8 and pip on CentOS8
Python conda on cygwin
Install python on WSL
Operate Redmine using Python Redmine
PyOpenGL setup on Python 3
Install Python on Pidora.
Install Scrapy on python3
Fibonacci sequence using Python
Data analysis using Python 0
Dry-run sql query using psycopg2 on Redshift in Python
Install Python on Mac
Data cleaning using Python
Check types_map when using mimetypes on AWS Lambda (Python)
Installing pandas on python2.6
Using Python #external packages
python basic on windows ②
WiringPi-SPI communication using Python
Install python on windows
Age calculation using python