All Questions
Tagged with euclidean-distance dataframe
36
questions
11
votes
2
answers
18k
views
Find euclidean distance from a point to rows in pandas dataframe
i have a dataframe
id lat long
1 12.654 15.50
2 14.364 25.51
3 17.636 32.53
5 12.334 25.84
9 32.224 15.74
I want to find the euclidean distance of these ...
8
votes
2
answers
16k
views
Calculating pairwise Euclidean distance between all the rows of a dataframe
How can I calculate the Euclidean distance between all the rows of a dataframe? I am trying this code, but it is not working:
zero_data = data
distance = lambda column1, column2: pd.np.linalg.norm(...
5
votes
2
answers
4k
views
Distance matrix from two separate data frames
I'd like to create a matrix which contains the euclidean distances of the rows from one data frame versus the rows from another. For example, say I have the following data frames:
a <- c(1,2,3,4,5)...
4
votes
2
answers
4k
views
calculating average distance of nearest neighbours in pandas dataframe
I have a set of objects and their positions over time. I would like to get the distance between each car and their nearest neighbour, and calculate an average of this for each time point. An example ...
4
votes
4
answers
4k
views
How to apply euclidean distance function to a groupby object in pandas dataframe?
I have a set of objects and their positions over time. I would like to get the average distance between objects for each time point. An example dataframe is as follows:
time = [0, 0, 0, 1, 1, 2, 2]
x ...
3
votes
1
answer
6k
views
Distance between two sets of points [duplicate]
So after looking at various Questions asked here on stackoverflow I'm still not able to wrap my head around the dist function in R or maybe even a distance matrix in general.
So I have two dataframes ...
3
votes
3
answers
1k
views
Calculate euclidean distance between groups in a data frame
I have weekly data for various stores in the following form:
pd.DataFrame({'Store':['S1', 'S1', 'S1', 'S2','S2','S2','S3','S3','S3'], 'Week':[1, 2, 3,1,2,3,1,2,3],
'Sales' :...
2
votes
2
answers
2k
views
Pairwise Euclidean distance with pandas ignoring NaNs
I start with a dictionary, which is the way my data was already formatted:
import pandas as pd
dict2 = {'A': {'a':1.0, 'b':2.0, 'd':4.0}, 'B':{'a':2.0, 'c':2.0, 'd':5.0},
'C':{'b':1.0,'c':2.0, 'd':4....
2
votes
2
answers
95
views
Loop on a data frame with considering the types of the values
I have a large data set of coordinates and I want to calculate the Euclidean distance among them. The sample of that would be like this:
df <- data.frame("name" = c("a","b","c","a","e"), "type" = ...
2
votes
2
answers
436
views
How to get minimum values in dataframe below a certain threshold?
I have 2 dataframes in pandas containing locational information of cars and trees.
df1
x y
car
3 216 13
4 218 12
...
2
votes
1
answer
716
views
How to calculate sum of Euclidean distances from one datapoint to all other datapoints from pandas dataframe?
I have the following pandas dataframe:
import pandas as pd
import math
df = pd.DataFrame()
df['x'] = [2, 1, 3]
df['y'] = [2, 5, 6]
df['weight'] = [11, 12, 13]
print(df)
x y weight
0 ...
2
votes
0
answers
368
views
pyspark multidimensional scaling
I would like to perform a multidimensional scaling on pyspark DataFrame.
I know how to solve my problem using pandas + sklearn, but I am struggling with spark dataframe. Here is the pandas based ...
1
vote
4
answers
541
views
Compute Euclidian distance in 100 dimensions between many points: how to be fast?
I have a Pandas DataFrame of 2 million entries
Each entry is a point in a 100 dimensional space
I want to compute the Euclidian distance between the N last points and all the others to find the ...
1
vote
2
answers
2k
views
Finding pairs of latitude and longitude within a certain radius in Python
Given a dataframe df as follows:
id location lon lat
0 1 Onyx Spire 116.35425 39.87760
1 2 Unison Lookout 116.44333 39.93237
2 3 ...
1
vote
2
answers
2k
views
Calculate euclidean distance with R
I have data where rows are points and columns are coordinates x,y,z.
I'd like to calculate euclidean distance between points in couple, as 3-4, 11-12, 18-19 and so on... for example, I dont' need ...
1
vote
3
answers
3k
views
Calculate mean euclidean distance of multiple columns dataframe r
I have a dataframe that looks like this:
df <- data.frame(text = c("text1", "text2", "text3"),
a = c(1,2,3),
b = c(2,4,6),
c = c(3,6,9))
df
For each row I ...
1
vote
2
answers
473
views
Allocating clusters to data points stored in spark DataFrame
I have two spark DataFrames.
schema DataFrame A (stores cluster centroids):
cluster_id, dim1_pos, dim2_pos, dim3_pos, ..., dimN_pos
schema of DataFrame B (data points):
entity_id, dim1_pos, ...
1
vote
3
answers
2k
views
Calculating euclidean distance from a dataframe with several column features
I have a dataframe like below and I need to calculate the euclidean distance.
a,b,c,d,e
10,11,13,14,9
11,12,14,15,10
12,13,15,16,11
13,14,16,17,12
14,15,17,18,13
15,16,18,19,14
16,17,19,20,15
17,18,20,...
1
vote
1
answer
428
views
Find distance between rows in pandas dataframe but with reference to 1 row
In this pandas dataframe:
y_train feat1 feat2
0 9.596113 -7.900107
1 -1.384157 2.685313
2 -8.211954 5.214797
How do I go about adding a "distance from Class 0" column at ...
1
vote
1
answer
56
views
euclidian distance calculation from multiple tables with categorical variables
I have two data frames that looks like this:
df1 <- data.frame(geneID=c("gene1","gene2","gene3","gene4",
"gene5","...
1
vote
0
answers
333
views
euclidean distance between two dataframes
I have two dataframes. For simplicity assume, they each have only one entry
+--------------------+
| entry |
+----------------...
1
vote
1
answer
204
views
Minimum Euclidean Distance
I have two dataframes (attached image). For each of the given row in Table-1 -
Part1 - I need to find the row in Table-2 which gives the minimum Euclidian distance. Output-1 is the expected answer.
...
0
votes
2
answers
428
views
Calculate n-dimensional euclidean distance from group centroids for each sample and select the lowest 3 for each group in R
This is two-part question and is pretty complex.
First. I want to calculate the 'n'-dimensional euclidean distance between each individual sample in dataframe "ind_scores" and it's respective group ...
0
votes
1
answer
4k
views
how to calculate Euclidean distance between all rows of a data frame and the last row in r
I have a data frame and would like to calculate the Euclidean distance between all rows and the last row and add the distance value as a new column to data frame using distance function.
Do you have ...
0
votes
2
answers
2k
views
Running the same function multiple times and saving results with different names in workspace
So, I built a function called sort.song.
My goal with this function is to randomly sample the rows of a data.frame (DATA) and then filter it out (DATA.NEW) to analyse it. I want to do it multiple ...
0
votes
1
answer
230
views
How to change how distance is calculated in a scipy distance matrix?
I have the following dataframe (df):
x y
0 50 50
1 18 83
2 6 21
3 30 13
4 44 29
5 81 68
which corresponds to the x and y coordinates of 6 points.
I am using scipy's distance_matrix ...
0
votes
2
answers
909
views
euclidean distance between two big pandas dataframes
I have three dataframes df1 with 1 160 164 rows and 4 variables,df2 with 11241 rows and 4 variables, and df3 with 1 630 644 rows and 6 variables
df1 looks like :
df2 looks like :
The observations in ...
0
votes
1
answer
343
views
Euclidean distance and indicator from a large dataframe
I have a large Dataframe (189090, 8), I need to calculate Euclidean distance and the similarity.
My approach:
from scipy.spatial import KDTree
from scipy.spatial.distance import pdist
scaler = ...
0
votes
1
answer
42
views
Replace a 2D point in one dataframe with a 2D point in another dataframe if the Euclidean between them is the lowest
I have a data frame df1 with two columns V1 and V2 representing two coordinates of a point.
df1
V1 V2
1.30344679 0.060199021
1.256628917 0.095897457
0.954959945 0.237514922
1.240081297 0....
0
votes
1
answer
927
views
How to apply KMeans to get the centroid using dataframe with multiple features
I am following this detailed KMeans tutorial: https://github.com/python-engineer/MLfromscratch/blob/master/mlfromscratch/kmeans.py which uses dataset with 2 features.
But I have a dataframe with 5 ...
0
votes
1
answer
73
views
Computing values for a column in pandas using other columns
I have a data-frame containing 3 columns: 'longitude', 'latitude', and 'country'. For some longitude and latitudes, the value in the country columns is 'unknown'. Here is an overview of the data-frame:...
0
votes
2
answers
839
views
How to Calculate Euclidean distance from sf data frame points in R
How do I calculate Euclidean distance in km from a spatial point that has been converted from a geometry column into a data frame. (The points are points which were derived from a spatial join of ...
0
votes
1
answer
136
views
Pandas: concatenate dataframe with distance matrix
I tried to concatenate two Pandas DataFrames, but it concatenates wrong.
Initial dataset looks like:
df
>>>
well qoil cum_oil wct top_perf bot_perf st x ...
0
votes
0
answers
547
views
How to apply euclidean distance to dataframe. Calculate each row
Please help me, I have the problem. It's been about 2 weeks but I don't get it yet.
So, I want to use "apply" in dataframe, which I got from Alphavantage API.
I want to apply euclidean distance to ...
0
votes
1
answer
2k
views
Given specific lat/lon calculate closest point from csv list of lat/lon
Need help with efficient python code(using pandas) to find which vehicle at what time passed closest to incident_sw =(35.7158, -120.7640). I'm having trouble formulating a Euclidean distance to sort ...
-2
votes
1
answer
411
views
How to clustering based on the distance in Python pandas?
I have two dataframes with two groups of stations information. One for the 15 small stations and another for the 5 main stations.
Small Station Information(15*3):
SmallStation_ID longitude ...