当前位置: 首页>>代码示例>>Python>>正文


Python misc.reindex函数代码示例

本文整理汇总了Python中urbansim.utils.misc.reindex函数的典型用法代码示例。如果您正苦于以下问题:Python reindex函数的具体用法?Python reindex怎么用?Python reindex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了reindex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: households

def households(store):
    df = store['households']
    df = df[df.building_id > 0]  ##Revisit the allocation and remove GQ from synthetic population?
    
    p = store['parcels']
    b = store['buildings']
    b['luz'] = misc.reindex(p.luz_id, b.parcel_id)
    df['base_luz'] = misc.reindex(b.luz, df.building_id)
    df['segmentation_col'] = 1
    
    return df
开发者ID:spatialsmart,项目名称:sandiego_urbansim,代码行数:11,代码来源:datasources.py

示例2: luz_base_indicators

def luz_base_indicators(store):
    households = store['households'][['building_id']]
    jobs = store['jobs'][['building_id']]
    buildings = store['buildings'][['parcel_id']]
    parcels = store['parcels'][['luz_id']]
    buildings['luz_id'] = misc.reindex(parcels.luz_id, buildings.parcel_id)
    households['luz_id'] = misc.reindex(buildings.luz_id, households.building_id)
    jobs['luz_id'] = misc.reindex(buildings.luz_id, jobs.building_id)
    hh_luz_base = households.groupby('luz_id').size()
    emp_luz_base = jobs.groupby('luz_id').size()
    return pd.DataFrame({'hh_base':hh_luz_base, 'emp_base':emp_luz_base})
开发者ID:spatialsmart,项目名称:sandiego_urbansim,代码行数:11,代码来源:datasources.py

示例3: parcel_average_price

def parcel_average_price(use):
    if use == "residential":
        buildings = orca.get_table('buildings')
        s = misc.reindex(buildings.
                            res_price_per_sqft[buildings.general_type ==
                                              "Residential"].
                            groupby(buildings.luz_id).quantile(.85),
                            orca.get_table('parcels').luz_id).clip(150, 1250)
        return s
    return misc.reindex(orca.get_table('nodes')[use],
                        orca.get_table('parcels').node_id)
开发者ID:spatialsmart,项目名称:sandiego_urbansim,代码行数:11,代码来源:variables.py

示例4: scheduled_development_events

def scheduled_development_events(buildings, development_projects,
                                 demolish_events, summary, year, parcels,
                                 settings, years_per_iter, parcels_geography,
                                 building_sqft_per_job, vmt_fee_categories):

    # first demolish
    demolish = demolish_events.to_frame().\
        query("%d <= year_built < %d" % (year, year + years_per_iter))
    print "Demolishing/building %d buildings" % len(demolish)
    l1 = len(buildings)
    buildings = utils._remove_developed_buildings(
        buildings.to_frame(buildings.local_columns),
        demolish,
        unplace_agents=["households", "jobs"])
    orca.add_table("buildings", buildings)
    buildings = orca.get_table("buildings")
    print "Demolished %d buildings" % (l1 - len(buildings))
    print "    (this number is smaller when parcel has no existing buildings)"

    # then build
    dps = development_projects.to_frame().\
        query("%d <= year_built < %d" % (year, year + years_per_iter))

    if len(dps) == 0:
        return

    new_buildings = utils.scheduled_development_events(
        buildings, dps,
        remove_developed_buildings=False,
        unplace_agents=['households', 'jobs'])
    new_buildings["form"] = new_buildings.building_type.map(
        settings['building_type_map']).str.lower()
    new_buildings["job_spaces"] = new_buildings.non_residential_sqft / \
        new_buildings.building_type.fillna("OF").map(building_sqft_per_job)
    new_buildings["job_spaces"] = new_buildings.job_spaces.\
        fillna(0).astype('int')
    new_buildings["geom_id"] = parcel_id_to_geom_id(new_buildings.parcel_id)
    new_buildings["SDEM"] = True
    new_buildings["subsidized"] = False

    new_buildings["zone_id"] = misc.reindex(
        parcels.zone_id, new_buildings.parcel_id)
    new_buildings["vmt_res_cat"] = misc.reindex(
        vmt_fee_categories.res_cat, new_buildings.zone_id)
    del new_buildings["zone_id"]
    new_buildings["pda"] = parcels_geography.pda_id.loc[
        new_buildings.parcel_id].values

    summary.add_parcel_output(new_buildings)
开发者ID:ual,项目名称:bayarea_urbansim,代码行数:49,代码来源:models.py

示例5: write_parcel_output

    def write_parcel_output(self,
                            add_xy=None):
        """
        Write the parcel-level output to a csv file

        Parameters
        ----------
        add_xy : dictionary (optional)
            Used to add x, y values to the output - an example dictionary is
            pasted below - the parameters should be fairly self explanatory.
            Note that from_epsg and to_epsg can be omitted in which case the
            coordinate system is not changed.  NOTE: pyproj is required
            if changing coordinate systems::

                {
                    "xy_table": "parcels",
                    "foreign_key": "parcel_id",
                    "x_col": "x",
                    "y_col": "y",
                    "from_epsg": 3740,
                    "to_epsg": 4326
                }


        Returns
        -------
        Nothing
        """
        if self.parcel_output is None:
            return

        po = self.parcel_output
        if add_xy is not None:
            x_name, y_name = add_xy["x_col"], add_xy["y_col"]
            xy_joinname = add_xy["foreign_key"]
            xy_df = orca.get_table(add_xy["xy_table"])
            po[x_name] = misc.reindex(xy_df[x_name], po[xy_joinname])
            po[y_name] = misc.reindex(xy_df[y_name], po[xy_joinname])

            if "from_epsg" in add_xy and "to_epsg" in add_xy:
                import pyproj
                p1 = pyproj.Proj('+init=epsg:%d' % add_xy["from_epsg"])
                p2 = pyproj.Proj('+init=epsg:%d' % add_xy["to_epsg"])
                x2, y2 = pyproj.transform(p1, p2,
                                          po[x_name].values,
                                          po[y_name].values)
                po[x_name], po[y_name] = x2, y2

        po.to_csv(self.parcel_indicator_file, index_label="development_id")
开发者ID:AZMAG,项目名称:urbansim_defaults,代码行数:49,代码来源:utils.py

示例6: ln_pop_within_20min

def ln_pop_within_20min(zones, t_data_dist20):
    b = orca.merge_tables('buildings', tables=['buildings','parcels'], columns=['zone_id'])
    zonal_pop=zones.zonal_pop
    t_data=t_data_dist20.to_frame()
    t_data.loc[:,'attr']=zonal_pop[t_data_dist20.to_zone_id].values
    zone_time_range=t_data.groupby(level=0).attr.apply(np.sum)
    return reindex(zone_time_range, b.zone_id).apply(np.log1p)
开发者ID:apdjustino,项目名称:urbansim_old,代码行数:7,代码来源:new_variables.py

示例7: parcel_average_price

def parcel_average_price(use):
    if len(orca.get_table('nodes').index) == 0:
        return pd.Series(0, orca.get_table('parcels').index)
    if not use in orca.get_table('nodes').columns:
        return pd.Series(0, orca.get_table('parcels').index)
    return misc.reindex(orca.get_table('nodes')[use],
                        orca.get_table('parcels').node_id)
开发者ID:SANDAG,项目名称:sandag_urbansim,代码行数:7,代码来源:variables.py

示例8: ave_sqft_per_unit

def ave_sqft_per_unit(parcels, zones, settings):
    s = misc.reindex(zones.ave_unit_sqft, parcels.zone_id)

    clip = settings.get("ave_sqft_per_unit_clip", None)
    if clip is not None:
        s = s.clip(lower=clip['lower'], upper=clip['upper'])

    '''
    This is a fun feature that lets you set max dua for new contruction based
    on the dua (as an indicator of density and what part of the city we are).
    Example use in the YAML:

    clip_sqft_per_unit_based_on_dua:
      - threshold: 50
        max: 1000
      - threshold: 100
        max: 900
      - threshold: 150
        max: 800
    '''
    cfg = settings.get("clip_sqft_per_unit_based_on_dua", None)
    if cfg is not None:
        for clip in cfg:
            s[parcels.max_dua >= clip["threshold"]] = clip["max"]

    return s
开发者ID:ual,项目名称:bayarea_urbansim,代码行数:26,代码来源:variables.py

示例9: juris_ave_income

def juris_ave_income(households, buildings, parcels_geography, parcels):
    h = orca.merge_tables("households",
                          [households, buildings, parcels_geography],
                          columns=["jurisdiction_id", "income"])
    s = h.groupby(h.jurisdiction_id).income.quantile(.5)
    return misc.reindex(s, parcels_geography.jurisdiction_id).\
        reindex(parcels.index).fillna(s.median()).apply(np.log1p)
开发者ID:akselx,项目名称:bayarea_urbansim-1,代码行数:7,代码来源:variables.py

示例10: empden_zone_sector

def empden_zone_sector(sector, bzone_id):
    # non-interaction
    from variables_zones import number_of_jobs_of_sector
    zones = orca.get_table('zones')
    zone_density = number_of_jobs_of_sector(sector, zones, orca.get_table('jobs'))/zones.acres
    zone_density[~np.isfinite(zone_density)] = 0
    return misc.reindex(zone_density, bzone_id)
开发者ID:psrc,项目名称:urbansim2,代码行数:7,代码来源:variables_interactions.py

示例11: max_far

def max_far(parcels, zoning):
    sr = misc.reindex(zoning.max_far, parcels.zoning_id)
    sr = sr*parcels.proportion_developable
    df = pd.DataFrame({'max_far':sr.values}, index = sr.index.values)
    df['index'] = df.index.values
    df = df.drop_duplicates()
    del df['index']
    df.index.name = 'parcel_id'
    return df.max_far
开发者ID:kaseyklimes,项目名称:sandiego_urbansim,代码行数:9,代码来源:variables.py

示例12: move_jobs_from_portola_to_san_mateo_county

def move_jobs_from_portola_to_san_mateo_county(parcels, buildings, jobs_df):
    # need to move jobs from portola valley to san mateo county
    NUM_IN_PORTOLA = 1500

    juris = misc.reindex(
        parcels.juris, misc.reindex(buildings.parcel_id, jobs_df.building_id))

    # find jobs in portols valley to move
    portola = jobs_df[juris == "Portola Valley"]
    move = portola.sample(len(portola) - NUM_IN_PORTOLA)

    # find places in san mateo to which to move them
    san_mateo = jobs_df[juris == "San Mateo County"]
    move_to = san_mateo.sample(len(move))

    jobs_df.loc[move.index, "building_id"] = move_to.building_id.values

    return jobs_df
开发者ID:ual,项目名称:bayarea_urbansim,代码行数:18,代码来源:preprocessing.py

示例13: ave_sqft_per_unit

def ave_sqft_per_unit(parcels, nodes, settings):
    if len(nodes) == 0:
        # if nodes isn't generated yet
        return pd.Series(index=parcels.index)
    s = misc.reindex(nodes.ave_sqft_per_unit, parcels.node_id)
    clip = settings.get("ave_sqft_per_unit_clip", None)
    if clip is not None:
        s = s.clip(lower=clip['lower'], upper=clip['upper'])
    return s
开发者ID:spatialsmart,项目名称:sandiego_urbansim,代码行数:9,代码来源:variables.py

示例14: building_purchase_price_sqft

def building_purchase_price_sqft():
    # buildings = orca.get_table('buildings')
    # s = misc.reindex(buildings.res_price_per_sqft[buildings.general_type ==
                                          # "Residential"].
                        # groupby(buildings.luz_id).quantile(.4),
                        # orca.get_table('parcels').luz_id).clip(90, 700)
    s = misc.reindex(orca.get_table('nodes')['residential'],
                        orca.get_table('parcels').node_id)
    return s * .81 # In relation to Bay Area via RS Means metro scaling factor
开发者ID:spatialsmart,项目名称:sandiego_urbansim,代码行数:9,代码来源:variables.py

示例15: abstract_within_walking_distance_parcels

def abstract_within_walking_distance_parcels(attribute_name, parcels, gridcells, settings, walking_radius=None, **kwargs):
    gcl_values = parcels[attribute_name].groupby(parcels.grid_id).sum().reindex(gridcells.index).fillna(0) 
    res = misc.reindex(abstract_within_walking_distance_gridcells(gcl_values, gridcells, 
                cell_size=settings.get('cell_size', 150), walking_distance_circle_radius=(walking_radius or settings.get('cell_walking_radius', 600)), 
                mode=settings.get("wwd_correlate_mode", "reflect"), **kwargs), 
                        parcels.grid_id)
    #TODO: this step should not be needed if all parcels have an exisitng gridcell assigned
    res[np.isnan(res)] = 0
    return res    
开发者ID:psrc,项目名称:urbansim2,代码行数:9,代码来源:abstract_variables.py


注:本文中的urbansim.utils.misc.reindex函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。