本文整理汇总了Python中urbansim.utils.misc.data_dir函数的典型用法代码示例。如果您正苦于以下问题:Python data_dir函数的具体用法?Python data_dir怎么用?Python data_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了data_dir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: parcels_geography
def parcels_geography(parcels):
df = pd.read_csv(
os.path.join(misc.data_dir(), "02_01_2016_parcels_geography.csv"),
index_col="geom_id")
df = geom_id_to_parcel_id(df, parcels)
# this will be used to map juris id to name
juris_name = pd.read_csv(
os.path.join(misc.data_dir(), "census_id_to_name.csv"),
index_col="census_id").name10
df["juris_name"] = df.jurisdiction_id.map(juris_name)
df.loc[2054504, "juris_name"] = "Marin County"
df.loc[2054505, "juris_name"] = "Santa Clara County"
df.loc[2054506, "juris_name"] = "Marin County"
df.loc[572927, "juris_name"] = "Contra Costa County"
# assert no empty juris values
assert True not in df.juris_name.isnull().value_counts()
df["pda_id"] = df.pda_id.str.lower()
# danville wasn't supposed to be a pda
df["pda_id"] = df.pda_id.replace("dan1", np.nan)
return df
开发者ID:UDST,项目名称:bayarea_urbansim,代码行数:26,代码来源:datasources.py
示例2: maz
def maz():
maz = pd.read_csv(os.path.join(misc.data_dir(), "maz_geography.csv"))
maz = maz.drop_duplicates('MAZ').set_index('MAZ')
taz1454 = pd.read_csv(os.path.join(misc.data_dir(), "maz22_taz1454.csv"),
index_col='maz')
maz['taz1454'] = taz1454.TAZ1454
return maz
开发者ID:UDST,项目名称:bayarea_urbansim,代码行数:7,代码来源:datasources.py
示例3: taz_geography
def taz_geography():
tg = pd.read_csv(os.path.join(misc.data_dir(),
"taz_geography.csv"), index_col="zone")
sr = pd.read_csv(os.path.join(misc.data_dir(),
"superdistricts.csv"), index_col="number")
tg["subregion_id"] = sr.subregion.loc[tg.superdistrict].values
tg["subregion"] = tg.subregion_id.map({
1: "Core",
2: "Urban",
3: "Suburban",
4: "Rural"
})
return tg
开发者ID:bobbylu,项目名称:bayarea_urbansim-1,代码行数:13,代码来源:datasources.py
示例4: parcels_geography
def parcels_geography(parcels):
df = pd.read_csv(os.path.join(misc.data_dir(),
"02_01_2016_parcels_geography.csv"),
index_col="geom_id", dtype={'jurisdiction': 'str'})
df = geom_id_to_parcel_id(df, parcels)
juris_name = pd.read_csv(os.path.join(misc.data_dir(),
"census_id_to_name.csv"),
index_col="census_id").name10
df["juris_name"] = df.jurisdiction_id.map(juris_name)
df["pda_id"] = df.pda_id.str.lower()
return df
开发者ID:bobbylu,项目名称:bayarea_urbansim-1,代码行数:15,代码来源:datasources.py
示例5: local_pois
def local_pois(settings):
# because of the aforementioned limit of one netowrk at a time for the
# POIS, as well as the large amount of memory used, this is now a
# preprocessing step
n = make_network(
settings['build_networks']['walk']['name'],
"weight", 3000)
n.init_pois(
num_categories=1,
max_dist=3000,
max_pois=1)
cols = {}
locations = pd.read_csv(os.path.join(misc.data_dir(), 'bart_stations.csv'))
n.set_pois("tmp", locations.lng, locations.lat)
cols["bartdist"] = n.nearest_pois(3000, "tmp", num_pois=1)[1]
locname = 'pacheights'
locs = orca.get_table('landmarks').local.query("name == '%s'" % locname)
n.set_pois("tmp", locs.lng, locs.lat)
cols["pacheights"] = n.nearest_pois(3000, "tmp", num_pois=1)[1]
df = pd.DataFrame(cols)
df.index.name = "node_id"
df.to_csv('local_poi_distances.csv')
开发者ID:ual,项目名称:bayarea_urbansim,代码行数:27,代码来源:models.py
示例6: parcels
def parcels(store):
df = store['parcels']
df["zone_id"] = df.zone_id.replace(0, 1)
cfg = {
"fill_nas": {
"zone_id": {
"how": "mode",
"type": "int"
},
"shape_area": {
"how": "median",
"type": "float"
}
}
}
df = utils.table_reprocess(cfg, df)
# have to do it this way because otherwise it's a circular reference
sdem = pd.read_csv(os.path.join(misc.data_dir(),
"development_projects.csv"))
# mark parcels that are going to be developed by the sdem
df["sdem"] = df.geom_id.isin(sdem.geom_id).astype('int')
return df
开发者ID:bobbylu,项目名称:bayarea_urbansim-1,代码行数:25,代码来源:datasources.py
示例7: zoning_baseline
def zoning_baseline(parcels, zoning_lookup):
df = pd.read_csv(os.path.join(misc.data_dir(), "2015_08_13_zoning_parcels.csv"),
index_col="geom_id")
df = pd.merge(df, zoning_lookup.to_frame(), left_on="zoning_id", right_index=True)
df = geom_id_to_parcel_id(df, parcels)
d = {
"HS": "type1",
"HT": "type2",
"HM": "type3",
"OF": "type4",
"HO": "type5",
"IL": "type7",
"IW": "type8",
"IH": "type9",
"RS": "type10",
"RB": "type11",
"MR": "type12",
"MT": "type13",
"ME": "type14"
}
df.columns = [d.get(x, x) for x in df.columns]
return df
开发者ID:ual,项目名称:bayarea_urbansim_archive,代码行数:25,代码来源:datasources.py
示例8: development_projects
def development_projects(parcels, settings):
df = pd.read_csv(os.path.join(misc.data_dir(), "development_projects.csv"))
for fld in ['residential_sqft', 'residential_price', 'non_residential_price']:
df[fld] = 0
df["redfin_sale_year"] = 2012 # hedonic doesn't tolerate nans
df["stories"] = df.stories.fillna(1)
df["building_sqft"] = df.building_sqft.fillna(0)
df["non_residential_sqft"] = df.non_residential_sqft.fillna(0)
df["building_type_id"] = df.building_type.map(settings["building_type_map2"])
df = df.dropna(subset=["geom_id"]) # need a geom_id to link to parcel_id
df = df.dropna(subset=["year_built"]) # need a year built to get built
df["geom_id"] = df.geom_id.astype("int")
df = df.query('residential_units != "rent"')
df["residential_units"] = df.residential_units.astype("int")
df = df.set_index("geom_id")
df = geom_id_to_parcel_id(df, parcels).reset_index() # use parcel id
# we don't predict prices for schools and hotels right now
df = df.query("building_type_id <= 4 or building_type_id >= 7")
print "Describe of development projects"
print df[orca.get_table('buildings').local_columns].describe()
return df
开发者ID:ual,项目名称:bayarea_urbansim_archive,代码行数:28,代码来源:datasources.py
示例9: zoning_np
def zoning_np(parcels_geography):
scenario_zoning = pd.read_csv(os.path.join(misc.data_dir(),
'zoning_mods_np.csv'))
return pd.merge(parcels_geography.to_frame(),
scenario_zoning,
on=['jurisdiction', 'pda_id', 'tpp_id', 'exp_id'],
how='left')
开发者ID:ual,项目名称:bayarea_urbansim_archive,代码行数:7,代码来源:datasources.py
示例10: build_networks
def build_networks(settings):
name = settings["build_networks"]["name"]
st = pd.HDFStore(os.path.join(misc.data_dir(), name), "r")
nodes, edges = st.nodes, st.edges
net = pdna.Network(nodes["x"], nodes["y"], edges["from"], edges["to"], edges[["weight"]])
net.precompute(settings["build_networks"]["max_distance"])
return net
开发者ID:waddell,项目名称:urbansim_defaults,代码行数:7,代码来源:models.py
示例11: make_network
def make_network(name, weight_col, max_distance):
st = pd.HDFStore(os.path.join(misc.data_dir(), name), "r")
nodes, edges = st.nodes, st.edges
net = pdna.Network(nodes["x"], nodes["y"], edges["from"], edges["to"],
edges[[weight_col]])
net.precompute(max_distance)
return net
开发者ID:ual,项目名称:bayarea_urbansim,代码行数:7,代码来源:models.py
示例12: non_mandatory_accessibility
def non_mandatory_accessibility():
fname = get_logsum_file('non_mandatory')
df = pd.read_csv(os.path.join(
misc.data_dir(), fname))
df.loc[df.subzone == 0, 'subzone'] = 'c' # no walk
df.loc[df.subzone == 1, 'subzone'] = 'a' # short walk
df.loc[df.subzone == 2, 'subzone'] = 'b' # long walk
df['taz_sub'] = df.taz.astype('str') + df.subzone
return df.set_index('taz_sub')
开发者ID:UDST,项目名称:bayarea_urbansim,代码行数:9,代码来源:datasources.py
示例13: zoning_baseline
def zoning_baseline(parcels, zoning_lookup, settings):
df = pd.read_csv(os.path.join(misc.data_dir(),
"2015_12_21_zoning_parcels.csv"),
index_col="geom_id")
df = pd.merge(df, zoning_lookup.to_frame(),
left_on="zoning_id", right_index=True)
df = geom_id_to_parcel_id(df, parcels)
return df
开发者ID:UDST,项目名称:bayarea_urbansim,代码行数:9,代码来源:datasources.py
示例14: load_network_addons
def load_network_addons(network, file_name='PugetSoundNetworkAddons.h5'):
store = pd.HDFStore(os.path.join(misc.data_dir(), file_name), "r")
network.addons = {}
for attr in map(lambda x: x.replace('/', ''), store.keys()):
network.addons[attr] = pd.DataFrame({"node_id": network.node_ids.values}, index=network.node_ids.values)
tmp = store[attr].drop_duplicates("node_id")
tmp["has_poi"] = np.ones(tmp.shape[0], dtype="bool8")
network.addons[attr] = pd.merge(network.addons[attr], tmp, how='left', on="node_id")
network.addons[attr].set_index('node_id', inplace=True)
开发者ID:psrc,项目名称:urbansim2,代码行数:9,代码来源:utils.py
示例15: craigslist
def craigslist():
df = pd.read_csv(os.path.join(misc.data_dir(), "sfbay_craigslist.csv"))
net = orca.get_injectable('net')
df['node_id'] = net['walk'].get_node_ids(df['lon'], df['lat'])
df['tmnode_id'] = net['drive'].get_node_ids(df['lon'], df['lat'])
# fill nans -- missing bedrooms are mostly studio apts
df['bedrooms'] = df.bedrooms.replace(np.nan, 1)
df['neighborhood'] = df.neighborhood.replace(np.nan, '')
return df
开发者ID:MetropolitanTransportationCommission,项目名称:bayarea_urbansim,代码行数:9,代码来源:ual.py
示例16: zoning_lookup
def zoning_lookup():
df = pd.read_csv(os.path.join(misc.data_dir(), "zoning_lookup.csv"))
# this part is a bit strange - we do string matching on the names of zoning
# in order ot link parcels and zoning and some of the strings have small
# differences, so we copy the row and have different strings for the same
# lookup row. for now we drop duplicates of the id field in order to run
# in urbansim (all the attributes of rows that share an id are the same -
# only the name is different)
df = df.drop_duplicates(subset='id').set_index('id')
return df
开发者ID:bobbylu,项目名称:bayarea_urbansim-1,代码行数:10,代码来源:datasources.py
示例17: accessibilities_segmentation
def accessibilities_segmentation():
fname = get_logsum_file('segmentation')
df = pd.read_csv(os.path.join(
misc.data_dir(), fname))
df['AV'] = df['hasAV'].apply(lambda x: 'AV' if x == 1 else 'noAV')
df['label'] = (df['incQ_label'] + '_' + df['autoSuff_label'] +
'_' + df['AV'])
df = df.groupby('label').sum()
df['prop'] = df['num_persons'] / df['num_persons'].sum()
df = df[['prop']].transpose().reset_index(drop=True)
return df
开发者ID:UDST,项目名称:bayarea_urbansim,代码行数:11,代码来源:datasources.py
示例18: build_networks
def build_networks(parcels):
st = pd.HDFStore(os.path.join(misc.data_dir(), "osm_sandag.h5"), "r")
nodes, edges = st.nodes, st.edges
net = pdna.Network(nodes["x"], nodes["y"], edges["from"], edges["to"],
edges[["weight"]])
net.precompute(3000)
orca.add_injectable("net", net)
p = parcels.to_frame(parcels.local_columns)
p['node_id'] = net.get_node_ids(p['x'], p['y'])
orca.add_table("parcels", p)
开发者ID:spatialsmart,项目名称:sandiego_urbansim,代码行数:11,代码来源:models.py
示例19: load_network
def load_network(precompute=None, file_name='PugetSoundNetwork.h5'):
# load OSM from hdf5 file
store = pd.HDFStore(os.path.join(misc.data_dir(), file_name), "r")
nodes = store.nodes
edges = store.edges
nodes.index.name = "index" # something that Synthicity wanted to fix
# create the network
net=pdna.Network(nodes["x"], nodes["y"], edges["from"], edges["to"], edges[["distance"]])
if precompute is not None:
for dist in precompute:
net.precompute(dist)
return net
开发者ID:psrc,项目名称:urbansim2,代码行数:12,代码来源:utils.py
示例20: zoning_baseline
def zoning_baseline(parcels, zoning_lookup, settings):
df = pd.read_csv(os.path.join(misc.data_dir(),
"2015_12_21_zoning_parcels.csv"),
index_col="geom_id")
df = pd.merge(df, zoning_lookup.to_frame(),
left_on="zoning_id", right_index=True)
df = geom_id_to_parcel_id(df, parcels)
d = {k: "type%d" % v for k, v in settings["building_type_map2"].items()}
df.columns = [d.get(x, x) for x in df.columns]
return df
开发者ID:bobbylu,项目名称:bayarea_urbansim-1,代码行数:13,代码来源:datasources.py
注:本文中的urbansim.utils.misc.data_dir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论