featuretools.primitives.CityblockDistance#
- class featuretools.primitives.CityblockDistance(unit='miles')[source]#
Calculates the distance between points in a city road grid.
- Description:
This distance is calculated using the haversine formula, which takes into account the curvature of the Earth. If either input data contains NaN`s, the calculated distance with be `NaN. This calculation is also known as the Mahnattan distance.
- Parameters:
unit (str) – Determines the unit value to output. Could be miles or kilometers. Default is miles.
Examples
>>> cityblock_distance = CityblockDistance() >>> DC = (38, -77) >>> Boston = (43, -71) >>> NYC = (40, -74) >>> distances_mi = cityblock_distance([DC, DC], [NYC, Boston]) >>> np.round(distances_mi, 3).tolist() [301.519, 672.089]
We can also change the units in which the distance is calculated.
>>> cityblock_distance_kilometers = CityblockDistance(unit='kilometers') >>> distances_km = cityblock_distance_kilometers([DC, DC], [NYC, Boston]) >>> np.round(distances_km, 3).tolist() [485.248, 1081.622]
Methods
__init__([unit])flatten_nested_input_types(input_types)Flattens nested column schema inputs into a single list.
generate_name(base_feature_names)generate_names(base_feature_names)get_args_string()get_arguments()get_description(input_column_descriptions[, ...])get_filepath(filename)get_function()Attributes
base_ofbase_of_excludecommutativecompatibilityAdditional compatible libraries
default_valueDefault value this feature returns if no data found.
description_templateinput_typeswoodwork.ColumnSchema types of inputs
max_stack_depthnameName of the primitive
number_output_featuresNumber of columns in feature matrix associated with this feature
return_typeColumnSchema type of return
uses_calc_timeuses_full_dataframe