Ejemplo n.º 1
0
def main():
    """ select and run conversion function """
    
    args = docopt(__doc__, version="version=1.0.0")
    log.setLevel(int(args["--loglevel"]))
    log.info(args)

    filename = args["<filename>"]
    if filename.endswith(".py"):
        if args["--code"]:
            sys.exit("--code option only valid for ipynb => py")
        py2nb(filename)
    elif filename.endswith(".ipynb"):
        nb2py(filename, args["--code"])
Ejemplo n.º 2
0
sns.FacetGrid
    histograms by town
"""
from ipstartup import *
from logconfig import log
import logging
from houses.rightmove import get_properties, get_links
from houses.db import db, from_query
from tqdm import tqdm
import warnings
from analysis.plot import scatterplot
warnings.simplefilter(action = "ignore", category = RuntimeWarning)
warnings.simplefilter(action = "ignore", category = FutureWarning)
towns=["leamington", "solihull", "coventry",
       "selly oak", "edgbaston", "birmingham city centre"]
log.setLevel(logging.INFO)
#%% get data from web
for town in towns:
    log.info("getting %s"%town)
    salelinks, rentlinks = get_links(town)
    get_properties(tqdm(salelinks), town)
    get_properties(tqdm(rentlinks), town)
#%% prepare data
df = from_query(db.property, columns=db.property.fields)
# aggregate district
g=df.groupby(["town", "district", "bedrooms"])
dfd=g.agg(dict(priceperbed=[np.median, "count"],
              rentpppw=[np.median, "count"]))
dfd.columns = ['_'.join(col).strip() for col in dfd.columns.values]
dfd=dfd.rename(columns=dict(priceperbed_median="priceperbed",
                       priceperbed_count="sales",