Skip to content

Instantly share code, notes, and snippets.

@abbasali-io
Last active February 5, 2020 18:05
Show Gist options
  • Save abbasali-io/ef9aac8fd7338941f2ebe860896833e0 to your computer and use it in GitHub Desktop.
Save abbasali-io/ef9aac8fd7338941f2ebe860896833e0 to your computer and use it in GitHub Desktop.

Revisions

  1. abbasali-io revised this gist Feb 5, 2020. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion dsns_datablog_9.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,11 @@
    # create price per sqft
    df['Price_sqft'] = df['Price'] / df['Built_Size']

    # most expensive area by price per sqft
    dfc = df.copy(deep=True)

    # since we have infinite values in the data, for simplicity sake, we will drop these values
    dfc = dfc.replace([np.inf, -np.inf], np.nan).dropna(subset=["Price_sqft", "Price_room", "Rooms_sqft"], how="all") # replace infinite values with nan
    dfc = dfc.replace([np.inf, -np.inf], np.nan).dropna(subset=["Price_sqft"], how="all") # replace infinite values with nan

    all_property_price_sqft = dfc.groupby('Location')['Price_sqft'].mean().sort_values(ascending=False)

  2. abbasali-io created this gist Feb 5, 2020.
    12 changes: 12 additions & 0 deletions dsns_datablog_9.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # most expensive area by price per sqft
    dfc = df.copy(deep=True)

    # since we have infinite values in the data, for simplicity sake, we will drop these values
    dfc = dfc.replace([np.inf, -np.inf], np.nan).dropna(subset=["Price_sqft", "Price_room", "Rooms_sqft"], how="all") # replace infinite values with nan

    all_property_price_sqft = dfc.groupby('Location')['Price_sqft'].mean().sort_values(ascending=False)

    cx = all_property_price_sqft.plot(kind='bar', title="Property sq. ft. Price Distribution in Kuala Lumpur", figsize=(15,10), legend=True, fontsize=10, rot=90)
    cx.set_xlabel("Locations", fontsize=10)
    cx.set_ylabel("Expensivness", fontsize=10)
    plt.show()