This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. What is the most common room type in NYC Airbnb listings? | |
| 'entire home/apt' — 13266, but 'private room' pretty close | |
| SELECT room_type, count(*) FROM "room_types" | |
| GROUP BY room_type; | |
| 2. What is the average price of a listing by room type? | |
| shared - 53.65, entire – 197.17, private – 81.67 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # copying a part of userinfo, filling empty churn_date with the year end, getting months | |
| users2 = users[['user_id','reg_date','churn_date']].copy() | |
| users2['churn_date'] = users2['churn_date'].fillna(pd.to_datetime('2018-12-31', format='%Y-%m-%d') ) | |
| users2['reg_month'] = users2['reg_date'].dt.month | |
| users2['churn_month'] = users2['churn_date'].dt.month | |
| # black magic. making rows with months when the user was subscribed | |
| # 0 1 .. 12 | |
| # true false user_id | |
| def makemonths(row): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| f, (ax1, ax2) = plt.subplots(1, 2, figsize = (15, 15)) | |
| sns.barplot('people_per_market', 'state', hue = 'is_selected', | |
| dodge = False, data = markets_by_state, ax = ax1) | |
| sns.scatterplot('log_pop', 'log_markets', hue = 'is_selected', | |
| data = markets_by_state, ax = ax2, s = 100) | |
| ax1.legend_.remove() | |
| ax2.legend_.remove() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import seaborn as sns | |
| sns.set() #default sns style | |
| sns.set_style('whitegrid') # "white", "dark", "whitegrid", "darkgrid", "ticks" | |
| sns.set_palette('Purples') | |
| # divergent RdBu, PRGn, RdBu_r, PRGn_r | |
| # sequential Greys, Blues, PuRd, GnBu | |
| # bright, colorblind | |
| # custom ["#39A7D0", "#36ADA4"] |