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]
__init__(unit='miles')[source]#

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_of

base_of_exclude

commutative

compatibility

Additional compatible libraries

default_value

Default value this feature returns if no data found.

description_template

input_types

woodwork.ColumnSchema types of inputs

max_stack_depth

name

Name of the primitive

number_output_features

Number of columns in feature matrix associated with this feature

return_type

ColumnSchema type of return

series_library

stack_on

stack_on_exclude

stack_on_self

uses_calc_time

uses_full_dataframe