### Install UrbanSim from GitHub Source: https://udst.github.io/urbansim/gettingstarted.html Steps to clone the repository and install UrbanSim directly from source. ```bash git clone -b branch-name https://github.com/udst/urbansim.git cd urbansim pip install . ``` -------------------------------- ### Install UrbanSim Source: https://udst.github.io/urbansim/gettingstarted.html Commands to install the UrbanSim library using Pip or Conda package managers. ```bash pip install urbansim ``` ```bash conda install urbansim --channel conda-forge ``` -------------------------------- ### Start DataFrame Explorer Service Source: https://udst.github.io/urbansim/maps/index.html Starts the web service to serve Pandas queries and map visualizations. ```APIDOC ## Start DataFrame Explorer Service ### Description Starts the web service which serves the Pandas queries and generates the HTML for the map. The service runs on the specified host and port, accessible via a web browser. ### Method Python Function Call (urbansim.maps.dframe_explorer.start) ### Parameters - **views** (dict) - Required - Dictionary where keys are table names and values are dataframes. - **center** (list) - Optional - Initial latitude and longitude [lat, lon]. Default: [37.7792, -122.2191]. - **zoom** (int) - Optional - Initial zoom level. Default: 11. - **shape_json** (str) - Optional - Path to the GeoJSON file. Default: 'data/zones.json'. - **geom_name** (str) - Optional - Field name from JSON containing geometry ID. Default: 'ZONE_ID'. - **join_name** (str) - Optional - Column name in dataframes to join with geom_name. Default: 'zone_id'. - **precision** (int) - Optional - Precision of values in the legend. Default: 8. - **port** (int) - Optional - Port for the web service. Default: 8765. - **host** (str) - Optional - Hostname for the service. Default: 'localhost'. - **testing** (bool) - Optional - Whether to print debug information. Default: False. ``` -------------------------------- ### Upgrade UrbanSim Source: https://udst.github.io/urbansim/gettingstarted.html Commands to upgrade an existing UrbanSim installation. ```bash pip install urbansim --upgrade ``` ```bash conda update urbansim --channel conda-forge ``` -------------------------------- ### GET /urbansim/utils/misc/simulations_dir Source: https://udst.github.io/urbansim/utils/misc.html Retrieves the directory path for simulation configuration files. ```APIDOC ## GET /urbansim/utils/misc/simulations_dir ### Description Return the directory for the simulation configuration files (used by the website). ### Method GET ### Endpoint /urbansim/utils/misc/simulations_dir ### Response #### Success Response (200) - **path** (string) - The directory path for simulation configuration files. ``` -------------------------------- ### Pandas GroupBy Aggregation Example Source: https://udst.github.io/urbansim/maps/index.html This code demonstrates a Pandas aggregation using groupby and sum. It is an example of the interactive Pandas statements generated by the DataFrame Explorer's web service. ```python df.groupby('zone_id')['residential_units'].sum() ``` -------------------------------- ### Start DataFrame Explorer Service Source: https://udst.github.io/urbansim/maps/index.html Initiates the DataFrame Explorer web service. Open http://localhost:8765 in a web browser to access the service. This method requires a dictionary of DataFrames joined to shapes for visualization. ```python dframe_explorer.start() ``` -------------------------------- ### GET /urbansim/utils/misc/column_list Source: https://udst.github.io/urbansim/utils/misc.html Returns a list of column names that are present in the provided tables. ```APIDOC ## GET /urbansim/utils/misc/column_list ### Description Takes a list of tables and a list of column names and returns the columns that are present in the tables. ### Parameters #### Request Body - **tables** (sequence) - Required - Sequence of DataFrameWrapper or TableFuncWrapper objects. - **columns** (sequence) - Required - Sequence of strings representing column names of interest. ### Response #### Success Response (200) - **cols** (list) - List of column names available in the tables. ``` -------------------------------- ### GET /get_debug_info Source: https://udst.github.io/urbansim/developer/index.html Retrieves detailed debug information after running the pro forma for a given form and parking configuration. ```APIDOC ## GET /get_debug_info ### Description Get the debug info after running the pro forma for a given form and parking configuration. ### Method GET ### Parameters #### Query Parameters - **form** (string) - Required - The form to get debug info for. - **parking_config** (string) - Required - The parking configuration to get debug info for. ### Response #### Success Response (200) - **debug_info** (dataframe) - A dataframe where the index is the far with columns representing intermediate steps in the pro forma computation. ``` -------------------------------- ### GET /urbansim/utils/misc/runs_dir Source: https://udst.github.io/urbansim/utils/misc.html Retrieves the directory path for simulation run outputs. ```APIDOC ## GET /urbansim/utils/misc/runs_dir ### Description Return the directory for the run output. ### Method GET ### Endpoint /urbansim/utils/misc/runs_dir ### Response #### Success Response (200) - **path** (string) - The directory path for run output. ``` -------------------------------- ### GET /urbansim/utils/misc/column_map Source: https://udst.github.io/urbansim/utils/misc.html Resolves which columns come from which table. ```APIDOC ## GET /urbansim/utils/misc/column_map ### Description Takes a list of tables and a list of column names and resolves which columns come from which table. ### Parameters #### Request Body - **tables** (sequence) - Required - Sequence of DataFrameWrapper or TableFuncWrapper objects. - **columns** (sequence) - Required - Sequence of strings representing column names of interest. ### Response #### Success Response (200) - **col_map** (dict) - Maps table names to lists of column names. ``` -------------------------------- ### GET /urbansim/utils/misc/reports_dir Source: https://udst.github.io/urbansim/utils/misc.html Retrieves the directory path for report configuration files. ```APIDOC ## GET /urbansim/utils/misc/reports_dir ### Description Return the directory for the report configuration files (used by the website). ### Method GET ### Endpoint /urbansim/utils/misc/reports_dir ### Response #### Success Response (200) - **path** (string) - The directory path for report configuration files. ``` -------------------------------- ### Merge Pandas DataFrames Source: https://udst.github.io/urbansim/gettingstarted.html Example of merging building and parcel tables using a foreign key and index. ```python pd.merge(buildings, parcels, left_on="parcel_id", right_index=True, how="left") ``` -------------------------------- ### GET /get_ave_cost_sqft Source: https://udst.github.io/urbansim/developer/index.html Retrieves the average cost per square foot for a specific development form and parking configuration. ```APIDOC ## GET /get_ave_cost_sqft ### Description Get the average cost per sqft for the pro forma for a given form. ### Method GET ### Parameters #### Query Parameters - **form** (string) - Required - The form to get the average cost for. - **parking_config** (string) - Required - The parking configuration to get debug info for. ### Response #### Success Response (200) - **cost** (series) - A series where the index is the far and the values are the average cost per sqft at which the building is break even. ``` -------------------------------- ### Pandas GroupBy Mean Persons by Zone Source: https://udst.github.io/urbansim/maps/index.html Computes the mean number of persons per household by zone using Pandas groupby. This example illustrates calculating the average household size per zone. ```python households.groupby('zone_id').persons.mean() ``` -------------------------------- ### Pandas GroupBy Sum Persons by Zone Source: https://udst.github.io/urbansim/maps/index.html Computes the sum of persons by zone using Pandas groupby. This is an example of how the DataFrame Explorer aggregates disaggregate data to show zone populations. ```python households.groupby('zone_id').persons.sum() ``` -------------------------------- ### Run developer model to pick buildings Source: https://udst.github.io/urbansim/developer/index.html Initializes the developer model, computes target units, picks new buildings, and merges them into the existing building table. ```python dev = developer.Developer(feasibility.to_frame()) target_units = dev.\ compute_units_to_build(len(agents), buildings[supply_fname].sum(), target_vacancy) new_buildings = dev.pick(forms, target_units, parcel_size, ave_unit_size, total_units, max_parcel_size=max_parcel_size, drop_after_build=True, residential=residential, bldg_sqft_per_job=bldg_sqft_per_job) if year is not None: new_buildings["year_built"] = year if form_to_btype_callback is not None: new_buildings["building_type_id"] = new_buildings["form"].\ apply(form_to_btype_callback) all_buildings = dev.merge(buildings.to_frame(buildings.local_columns), new_buildings[buildings.local_columns]) sim.add_table("buildings", all_buildings) ``` -------------------------------- ### urbansim.models.transition Module Source: https://udst.github.io/urbansim/genindex.html Details about classes and methods within the urbansim.models.transition module. ```APIDOC ## Classes in urbansim.models.transition ### TabularGrowthRateTransition - **Description**: Represents a transition model based on tabular growth rates. - **Methods**: - `transition()` - `to_dict()` - `to_yaml()` ### TabularTotalsTransition - **Description**: Represents a transition model based on tabular totals. - **Methods**: - `transition()` - `to_dict()` - `to_yaml()` ### TransitionModel - **Description**: Base class for transition models. - **Methods**: - `transition()` - `to_dict()` - `to_yaml()` ``` -------------------------------- ### Simulate Residential Sales Hedonic Model Source: https://udst.github.io/urbansim/examples.html Defines the entry point for simulating the residential sales hedonic model. It uses a configuration file and specifies the attribute to store the results. ```python @orca.step('rsh_simulate') def rsh_simulate(buildings, zones): return utils.hedonic_simulate("rsh.yaml", buildings, zones, "residential_sales_price") ``` -------------------------------- ### Estimate Residential Sales Hedonic Model Source: https://udst.github.io/urbansim/examples.html Defines the entry point for estimating the residential sales hedonic model using a configuration file. It calls a helper function from `utils.py`. ```python @orca.step('rsh_estimate') def rsh_estimate(buildings, zones): return utils.hedonic_estimate("rsh.yaml", buildings, zones) ``` -------------------------------- ### pick Source: https://udst.github.io/urbansim/developer/index.html Selects feasible buildings to build based on specified demand and constraints. ```APIDOC ## pick ### Description Choose the buildings from the list that are feasible to build in order to match the specified demand. ### Parameters - **form** (string or list) - Required - Building forms from the pro forma specification - **target_units** (int) - Required - Number of units or job spaces to build - **parcel_size** (series) - Required - Size of the parcels - **ave_unit_size** (series) - Required - Average residential unit size around each parcel - **bldg_sqft_per_job** (float) - Optional - Average square feet per job (default 400.0) - **min_unit_size** (float) - Optional - Minimum unit size threshold - **current_units** (series) - Required - Current number of units on the parcel - **max_parcel_size** (float) - Optional - Maximum parcel size for consideration - **drop_after_build** (bool) - Optional - Whether to drop parcels after development - **residential** (bool) - Optional - Set to false for non-residential buildings - **profit_to_prob_func** (function) - Optional - Function to return probabilities from feasibility dataframe ### Response - **new_buildings** (dataframe) - DataFrame of buildings to add ``` -------------------------------- ### Urbansim Modules Overview Source: https://udst.github.io/urbansim/genindex.html List of available modules within the Urbansim library. ```APIDOC ## Urbansim Modules - `urbansim.developer.developer` - `urbansim.developer.sqftproforma` - `urbansim.maps.dframe_explorer` - `urbansim.models.dcm` - `urbansim.models.regression` - `urbansim.models.relocation` - `urbansim.models.supplydemand` - `urbansim.models.transition` - `urbansim.models.util` - `urbansim.urbanchoice.interaction` - `urbansim.urbanchoice.mnl` - `urbansim.utils.misc` - `urbansim.utils.testing` - `urbansim.utils.yamlio` ``` -------------------------------- ### Initialize SqFtProForma and Test Parcel Feasibility Source: https://udst.github.io/urbansim/developer/index.html Initializes the SqFtProForma object and converts parcel data to a DataFrame for feasibility testing. This is a prerequisite for calculating real estate feasibility for a set of parcels. ```python pf = sqftproforma.SqFtProForma() df = parcels.to_frame() # add prices for each use for use in pf.config.uses: df[use] = parcel_price_callback(use) ``` -------------------------------- ### SqFtProFormaConfig Class Configuration Source: https://udst.github.io/urbansim/developer/index.html This section details the parameters used to configure the SqFtProFormaConfig class for square foot based pro forma calculations. ```APIDOC ## SqFtProFormaConfig Class ### Description This class encapsulates the configuration options for the square foot based pro forma. ### Parameters #### Request Body Parameters - **parcel_sizes** (list) - Required - A list of parcel sizes to test. All sizes can be feet or meters as long as they are consistently used. - **fars** (list) - Required - A list of floor area ratios to use. FAR is a multiple of the parcel size that is the total building bulk that is allowed by zoning on the site. - **uses** (list) - Required - A list of space uses to use within a building. By default, uses are retail, industrial, office, and residential. - **forms** (dict) - Required - A dictionary where keys are names for the form and values are also dictionaries where keys are uses and values are the proportion of that use used in this form. The values of the dictionary should sum to 1.0. - **parking_rates** (dict) - Required - A dict of rates per thousand square feet where keys are the uses from the list specified in the attribute above. The ratios are typically in the range 0.5 - 3.0 or similar. - **sqft_per_rate** (float) - Optional - The number of square feet per unit for use in the parking_rates above. By default this is set to 1,000 but can be overridden. - **parking_configs** (list) - Optional - An expert parameter and is usually unchanged. By default it is set to ['surface', 'deck', 'underground']. - **parking_sqft_d** (dict) - Optional - A dictionary where keys are the three parking configurations listed above and values are square foot uses of parking spaces in that configuration. - **parking_cost_d** (dict) - Optional - The parking cost for each parking configuration. Keys are the name of the three parking configurations listed above and values are dollars PER SQUARE FOOT for parking in that configuration. - **height_for_costs** (list) - Optional - A list of “break points” as heights at which construction becomes more expensive. Generally these are the heights at which construction materials change from wood, to concrete, to steel. - **costs** (dict) - Optional - The keys are uses from the attribute above and the values are a list of floating point numbers of same length as the height_for_costs attribute. - **height_per_story** (float) - Optional - The per-story height for the building used to turn an FAR into an actual height. - **max_retail_height** (float) - Optional - The maximum height of retail buildings to consider. - **max_industrial_height** (float) - Optional - The maximum height of industrial buildings to consider. - **profit_factor** (float) - Optional - ### Request Example ```json { "parcel_sizes": [10000], "fars": [1.0, 2.0, 3.0], "uses": ["retail", "industrial", "office", "residential"], "forms": { "residential": {"residential": 1.0}, "mixed": {"retail": 0.1, "residential": 0.9} }, "parking_rates": {"retail": 2.0, "industrial": 1.0, "office": 1.5, "residential": 0.5}, "sqft_per_rate": 1000, "parking_configs": ["surface", "deck", "underground"], "parking_sqft_d": {"surface": 300, "deck": 250, "underground": 200}, "parking_cost_d": {"surface": 5, "deck": 15, "underground": 25}, "height_for_costs": [15, 55, 120, Infinity], "costs": { "residential": [160.0, 175.0, 200.0, 230.0], "retail": [170.0, 185.0, 210.0, 240.0] }, "height_per_story": 10, "max_retail_height": 50, "max_industrial_height": 100, "profit_factor": 1.2 } ``` ``` -------------------------------- ### POST /lookup Source: https://udst.github.io/urbansim/developer/index.html Performs developer model lookups for input parcel data to determine building feasibility. ```APIDOC ## POST /lookup ### Description This function does the developer model lookups for all the actual input data. ### Method POST ### Parameters #### Request Body - **form** (string) - Required - One of the forms specified in the configuration file. - **df** (dataframe) - Required - Dataframe indexed by parcel_id containing columns: rent, land_cost, parcel_size, max_far, max_height, max_dua (optional), ave_unit_size (optional). - **only_built** (bool) - Optional - Whether to return only profitable buildings. - **pass_through** (list of strings) - Optional - List of field names to pass to the output feasibility frame. ### Response #### Success Response (200) - **index** (Series) - Parcel identifiers. - **building_sqft** (Series) - The number of square feet for the building. - **building_cost** (Series) - The cost of constructing the building. - **total_cost** (Series) - The cost of constructing the building plus acquisition cost. - **building_revenue** (Series) - The revenue generated by the building. ``` -------------------------------- ### compute_units_to_build Source: https://udst.github.io/urbansim/developer/index.html Calculates the number of units required to reach a target vacancy rate. ```APIDOC ## STATIC compute_units_to_build ### Description Compute number of units to build to match target vacancy. ### Parameters - **num_agents** (int) - Required - number of agents that need units in the region - **num_units** (int) - Required - number of units in buildings - **target_vacancy** (float) - Required - target vacancy rate (0-1.0) ### Response - **number_of_units** (int) - the number of units that need to be built ``` -------------------------------- ### Compute building feasibility Source: https://udst.github.io/urbansim/developer/index.html Calculates feasibility for various forms and adds the resulting table to the simulation. ```python if residential_to_yearly: df["residential"] *= pf.config.cap_rate d = {} for form in pf.config.forms: print "Computing feasibility for form %s" % form d[form] = pf.lookup(form, df[parcel_use_allowed_callback(form)]) far_predictions = pd.concat(d.values(), keys=d.keys(), axis=1) sim.add_table("feasibility", far_predictions) ``` -------------------------------- ### UrbanSim Module Index Source: https://udst.github.io/urbansim/py-modindex.html A list of available modules within the urbansim package. ```APIDOC ## UrbanSim Python Modules ### Description The following modules are available in the `urbansim` package: - `urbansim.developer.developer` - `urbansim.developer.sqftproforma` - `urbansim.maps.dframe_explorer` - `urbansim.models.dcm` - `urbansim.models.regression` - `urbansim.models.relocation` - `urbansim.models.supplydemand` - `urbansim.models.transition` - `urbansim.models.util` - `urbansim.urbanchoice.interaction` - `urbansim.urbanchoice.mnl` - `urbansim.utils.misc` - `urbansim.utils.testing` - `urbansim.utils.yamlio` ``` -------------------------------- ### urbansim.utils.yamlio Module Source: https://udst.github.io/urbansim/genindex.html Utilities for handling YAML data within Urbansim. ```APIDOC ## Functions in urbansim.utils.yamlio ### to_scalar_safe() - **Description**: Safely converts a value to a scalar. ### yaml_to_dict() - **Description**: Converts YAML content to a Python dictionary. ``` -------------------------------- ### UrbanSim Modeling Workflow Pseudocode Source: https://udst.github.io/urbansim/gettingstarted.html Represents the high-level sequence of model estimation followed by iterative simulation over a specified time horizon. ```pseudocode for model in models: model.estimate(model_configuration_parameters) for i in range(NUMYEARSINSIMULATION): for model in models: model.simulate(model_configuration_parameters) ``` -------------------------------- ### urbansim.models.regression Module Source: https://udst.github.io/urbansim/genindex.html Regression model utilities. ```APIDOC ## Classes in urbansim.models.regression ### RegressionModel - **Description**: Base class for regression models. - **Methods**: - `to_dict()` - `to_yaml()` ### SegmentedRegressionModel - **Description**: Represents a segmented regression model. - **Methods**: - `to_dict()` - `to_yaml()` ``` -------------------------------- ### Urbansim Models and Utilities Source: https://udst.github.io/urbansim/genindex.html This section details various functions and classes within the Urbansim library, including model manipulation, data utilities, and testing helpers. ```APIDOC ## add_model() ### Description Adds a model to a model group. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## add_model_from_params() ### Description Adds a model to a model group using provided parameters. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## add_or_remove_rows() ### Description Adds or removes rows from a dataset. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## add_rows() ### Description Adds rows to a dataset. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## add_segment() ### Description Adds a segment to a segmented model. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## alts_columns_used() ### Description Returns the columns used by the alternatives in a discrete choice model. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## apply_filter_query() ### Description Applies a filter query to a dataset. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## apply_fit_filters() ### Description Applies filters to the data before fitting a model. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## apply_predict_filters() ### Description Applies filters to the data before making predictions. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## assert_fitted() ### Description Asserts that a model has been fitted. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## assert_frames_equal() ### Description Asserts that two pandas DataFrames are equal. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## assert_index_equal() ### Description Asserts that two pandas Index objects are equal. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## charts_dir() ### Description Returns the path to the charts directory. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## choosers_columns_used() ### Description Returns the columns used by the choosers in a discrete choice model. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## column_list() ### Description Returns a list of column names. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## column_map() ### Description Returns a mapping of column names. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## columns_in_filters() ### Description Returns the columns used in filters. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## columns_in_formula() ### Description Returns the columns used in a formula. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## columns_used() ### Description Returns the columns used by the model. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## compute_range() ### Description Computes the range of a dataset. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## compute_units_to_build() ### Description Computes the number of units to build. ### Method Static Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## concat_indexes() ### Description Concatenates pandas Index objects. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## config() ### Description Returns the configuration settings. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## configs_dir() ### Description Returns the path to the configurations directory. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## convert_to_yaml() ### Description Converts data to YAML format. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## data_dir() ### Description Returns the path to the data directory. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## df64bitto32bit() ### Description Converts a 64-bit DataFrame to 32-bit. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## edits_dir() ### Description Returns the path to the edits directory. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## enable_gpu() ### Description Enables GPU support for urbanchoice interaction. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## fidx() ### Description Calculates a fixed index. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## filter_table() ### Description Filters a table based on specified criteria. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## find_movers() ### Description Finds movers based on relocation model criteria. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## fit() ### Description Fits the model to the data. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## fit_from_cfg() ### Description Fits the model from a configuration. ### Method Class Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## fit_model() ### Description Fits a regression model. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## fitted() ### Description Property to check if the model is fitted. ### Method Property ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## frame_to_yaml_safe() ### Description Safely converts a DataFrame to YAML format. ### Method Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## from_yaml() ### Description Loads data from YAML format. ### Method Class Method ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### urbansim.models.dcm.MNLDiscreteChoiceModel Source: https://udst.github.io/urbansim/genindex.html Methods for MNL Discrete Choice Model. ```APIDOC ## Methods for urbansim.models.dcm.MNLDiscreteChoiceModel ### to_dict() - **Description**: Converts the model to a dictionary representation. ### to_yaml() - **Description**: Converts the model to a YAML representation. ``` -------------------------------- ### Syntactically Awkward but Faster Groupby Source: https://udst.github.io/urbansim/examples.html This approach improves performance by converting only the necessary columns to a DataFrame before the groupby operation, though the syntax is more verbose. ```python return buildings.to_frame(['zone_id', 'residential_units']).groupby("zone_id").residential_units.sum() ``` -------------------------------- ### urbansim.models.dcm Module Source: https://udst.github.io/urbansim/genindex.html Discrete Choice Model utilities. ```APIDOC ## Functions in urbansim.models.dcm ### unit_choice() - **Description**: Calculates unit choice probabilities. ``` -------------------------------- ### Data Conversion Utilities Source: https://udst.github.io/urbansim/utils/yamlio.html Helper functions for converting pandas objects and numpy types to YAML-safe formats. ```APIDOC ## frame_to_yaml_safe Convert a pandas DataFrame to a dictionary that will survive YAML serialization. ## series_to_yaml_safe Convert a pandas Series to a dict that will survive YAML serialization. ## to_scalar_safe Convert a numpy data type to a standard python scalar. ``` -------------------------------- ### Define Household Table Source with Orca Source: https://udst.github.io/urbansim/examples.html Registers a data source for the 'households' table using the orca.table decorator. The data is loaded from an HDF5 store. ```python import orca @orca.table('households') def households(store): df = store['households'] return df ``` -------------------------------- ### assert_index_equal Source: https://udst.github.io/urbansim/utils/testing.html Compares two pandas Indexes for equality, similar to pandas.testing.assert_index_equal but is not sensitive to the order of elements. ```APIDOC ## assert_index_equal ### Description Similar to pdt.assert_index_equal but is not sensitive to key ordering. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **left** (pandas.Index) - The first index to compare. - **right** (pandas.Index) - The second index to compare. ### Request Example None ### Response None #### Success Response (200) None #### Response Example None ``` -------------------------------- ### urbansim.utils.yamlio.yaml_to_dict Source: https://udst.github.io/urbansim/utils/yamlio.html Loads YAML data from a string, file, or buffer into a dictionary. ```APIDOC ## yaml_to_dict ### Description Load YAML from a string, file, or buffer (an object with a .read method). Parameters are mutually exclusive. ### Parameters - **yaml_str** (str) - Optional - A string of YAML. - **str_or_buffer** (str or file like) - Optional - File name or buffer from which to load YAML. - **ordered** (bool) - Optional - If True, an OrderedDict is returned. ### Response - **Returns** (dict) - Conversion from YAML. ``` -------------------------------- ### YAML Configuration for Regression Model Source: https://udst.github.io/urbansim/examples.html Defines parameters for a regression model, including fit and predict filters, model expression, and y-transformation. Use this for specifying statistical models in YAML. ```yaml name: rsh model_type: regression fit_filters: - unit_lot_size > 0 - year_built > 1000 - year_built < 2020 - unit_sqft > 100 - unit_sqft < 20000 predict_filters: - general_type == 'Residential' model_expression: np.log1p(residential_sales_price) ~ I(year_built < 1940) + I(year_built > 2005) + np.log1p(unit_sqft) + np.log1p(unit_lot_size) + sum_residential_units + ave_lot_sqft + ave_unit_sqft + ave_income ytransform: np.exp ``` -------------------------------- ### Configure NaN handling with orca Source: https://udst.github.io/urbansim/examples.html Defines an injectable configuration for filling missing values in specific table columns. The configuration maps table and column names to a fill strategy and target data type. ```python orca.add_injectable("fillna_config", { "buildings": { "residential_sales_price": ("zero", "int"), "non_residential_rent": ("zero", "int"), "residential_units": ("zero", "int"), "non_residential_sqft": ("zero", "int"), "year_built": ("median", "int"), "building_type_id": ("mode", "int") }, "jobs": { "job_category": ("mode", "str"), } }) ``` -------------------------------- ### Register Buildings Table with Orca Source: https://udst.github.io/urbansim/gettingstarted.html Use the @orca.table decorator to register a 'buildings' table. This function assumes a 'store' object is available for data retrieval. ```python @orca.table('buildings') def buildings(store): return store['buildings'] ``` -------------------------------- ### urbansim.utils.yamlio.convert_to_yaml Source: https://udst.github.io/urbansim/utils/yamlio.html Converts a dictionary to YAML format, either returning the string or writing it to a file or buffer. ```APIDOC ## convert_to_yaml ### Description Convert a dictionary to YAML and return the string or write it out depending on the type of str_or_buffer. ### Parameters - **cfg** (dict or OrderedDict) - Required - Dictionary or OrderedDict to convert. - **str_or_buffer** (None, str, or buffer) - Required - If None: the YAML string will be returned. If string: YAML will be saved to a file. If buffer: YAML will be written to buffer using the .write method. ### Response - **Returns** (str or None) - YAML string if str_or_buffer is None, otherwise None. ``` -------------------------------- ### urbansim.models.dcm.SegmentedMNLDiscreteChoiceModel Source: https://udst.github.io/urbansim/genindex.html Methods for Segmented MNL Discrete Choice Model. ```APIDOC ## Methods for urbansim.models.dcm.SegmentedMNLDiscreteChoiceModel ### to_dict() - **Description**: Converts the model to a dictionary representation. ### to_yaml() - **Description**: Converts the model to a YAML representation. ``` -------------------------------- ### POST /urbansim/utils/misc/series64bitto32bit Source: https://udst.github.io/urbansim/utils/misc.html Converts a Pandas series from 64-bit to 32-bit types to optimize memory usage. ```APIDOC ## POST /urbansim/utils/misc/series64bitto32bit ### Description Convert a Pandas series from 64 bit types to 32 bit types to save memory or disk space. ### Method POST ### Endpoint /urbansim/utils/misc/series64bitto32bit ### Parameters #### Request Body - **s** (Pandas Series) - Required - The series to convert ### Response #### Success Response (200) - **series** (Pandas Series) - The converted series ``` -------------------------------- ### Assert Indexes Equal - UrbanSim Testing Source: https://udst.github.io/urbansim/utils/testing.html Compares two pandas Indexes for equality, insensitive to the order of elements. This is a variation of `pdt.assert_index_equal`. ```python assert_index_equal(left, right) ``` -------------------------------- ### POST /urbansim/utils/misc/pandasdfsummarytojson Source: https://udst.github.io/urbansim/utils/misc.html Converts a Pandas describe operation result to JSON. ```APIDOC ## POST /urbansim/utils/misc/pandasdfsummarytojson ### Description Convert the result of a Pandas describe operation to a JSON object. ### Parameters #### Request Body - **df** (dataframe) - Required - The result of a Pandas describe operation. - **ndigits** (int) - Optional - The number of significant digits to round to (default 3). ### Response #### Success Response (200) - **json** (object) - A json object which captures the describe. ``` -------------------------------- ### POST /urbansim/utils/misc/df64bitto32bit Source: https://udst.github.io/urbansim/utils/misc.html Converts a Pandas dataframe from 64-bit to 32-bit types. ```APIDOC ## POST /urbansim/utils/misc/df64bitto32bit ### Description Convert a Pandas dataframe from 64 bit types to 32 bit types to save memory or disk space. ### Parameters #### Request Body - **tbl** (dataframe) - Required - The dataframe to convert. ### Response #### Success Response (200) - **result** (dataframe) - The converted dataframe. ``` -------------------------------- ### Reindex Zone ID to Buildings Table Source: https://udst.github.io/urbansim/examples.html Moves the 'zone_id' attribute from the 'parcels' table to the 'buildings' table using 'parcel_id' as the foreign key. This is useful for associating building data with their respective zones. ```python @orca.column('buildings', 'zone_id', cache=True) def zone_id(buildings, parcels): return misc.reindex(parcels.zone_id, buildings.parcel_id) ``` -------------------------------- ### POST /urbansim/utils/misc/signif Source: https://udst.github.io/urbansim/utils/misc.html Converts a statistical significance value to its ASCII representation. ```APIDOC ## POST /urbansim/utils/misc/signif ### Description Convert a statistical significance to its ascii representation - this should be the same representation created in R. ### Method POST ### Endpoint /urbansim/utils/misc/signif ### Parameters #### Request Body - **val** (float) - Required - The statistical significance value to convert ### Response #### Success Response (200) - **representation** (string) - The ASCII representation of the significance value. ``` -------------------------------- ### Efficiently Groupby Residential Units Source: https://udst.github.io/urbansim/examples.html This is the recommended way to perform a groupby operation on a specific Series within a DataFrameWrapper, ensuring efficiency by avoiding unnecessary computations. ```python return buildings.residential_units.groupby(buildings.zone_id).sum() ``` -------------------------------- ### Register Parcels Table with Orca Source: https://udst.github.io/urbansim/gettingstarted.html Use the @orca.table decorator to register a 'parcels' table. This function assumes a 'store' object is available for data retrieval. ```python @orca.table('parcels') def parcels(store): return store['parcels'] ``` -------------------------------- ### Add Building Type Map Injectable Source: https://udst.github.io/urbansim/examples.html Adds a Python dictionary as an injectable named 'building_type_map' using sim.add_injectable. This map is used to reduce dimensionality by mapping building type IDs to general building types. ```python # this maps building type ids to general building types # basically just reduces dimensionality sim.add_injectable("building_type_map", { 1: "Residential", 2: "Residential", 3: "Residential", 4: "Office", 5: "Hotel", 6: "School", 7: "Industrial", 8: "Industrial", 9: "Industrial", 10: "Retail", 11: "Retail", 12: "Residential", 13: "Retail", 14: "Office" }) ``` -------------------------------- ### Groupby with Local Columns Source: https://udst.github.io/urbansim/examples.html This method is efficient when all attributes used in the groupby operation are primary attributes. It uses `local_columns` to select only the necessary primary attributes. ```python return buildings.to_frame(buildings.local_columns).groupby("zone_id").residential_units.sum() ```