python-scipyHow can I calculate the distance between two points using Python and SciPy?
The distance between two points can be calculated using Python and SciPy with the following code:
from scipy.spatial import distance
point1 = (1, 2)
point2 = (4, 6)
dist = distance.euclidean(point1, point2)
print(dist)
This will output 5.0.
The code uses the following parts:
from scipy.spatial import distanceimports the distance module from SciPy.point1andpoint2are tuples containing the coordinates of the two points.distance.euclidean(point1, point2)calculates the Euclidean distance between the two points.print(dist)prints the distance to the console.
Helpful links
More of Python Scipy
- How can I use Python and SciPy to find the zeros of a function?
- How do I use Python Scipy to perform a Z test?
- How can I use Python and Numpy to parse XML data?
- How do I calculate the variance with Python and NumPy?
- How do I upgrade my Python Scipy package?
- How do I use the NumPy transpose function in Python?
- How do I perform a t-test using Python and SciPy?
- How can I use Python and SciPy to process signals?
- How can I use Python Scipy to create a tutorial?
- How do I rotate an image using Python and SciPy?
See more codes...