PMende posted a NumPy solution while I was working on mine, and it's even better. Kudos to him.
Here is a slight variation on his answer which I like because it doesn't use any explicit loops.
raw_str = \
'''
ID X Y mRNA
0 0 149.492 189.153 0
1 1 115.084 194.082 2
2 2 135.331 194.831 7
3 3 136.965 184.493 2
4 4 124.025 190.069 1
2410 2410 452.596 256.313 0
2411 2411 196.448 333.959 46
2412 2412 190.779 318.418 71
2413 2413 202.941 335.446 37
2414 2414 254.967 369.431 13
'''
df_1 = pd.read_csv(StringIO(raw_str), header=0, delim_whitespace=True, usecols=[1, 2, 3, 4])
coords = df_1[['X', 'Y']].to_numpy()
distances = spsp.distance_matrix(coords, coords)
col_names = df_1['ID'].map(lambda x: f'col_id_{x}').rename()
df_2 = pd.DataFrame(data=distances, columns=col_names)
df_3 = pd.concat((df_1, df_2), axis=1)
The extra variables obviously hurt performance, they're here simply for the sake of clarity.
Creating thousands of columns is kind of crazy, this is a more reasonable solution which saves the distances as lists in each row.
from io import StringIO
import pandas as pd
import scipy.spatial as spsp
raw_str = \
'''
ID X Y mRNA
0 0 149.492 189.153 0
1 1 115.084 194.082 2
2 2 135.331 194.831 7
3 3 136.965 184.493 2
4 4 124.025 190.069 1
2410 2410 452.596 256.313 0
2411 2411 196.448 333.959 46
2412 2412 190.779 318.418 71
2413 2413 202.941 335.446 37
2414 2414 254.967 369.431 13
'''
df_1 = pd.read_csv(StringIO(raw_str), header=0, delim_whitespace=True, usecols=[1, 2, 3, 4])
coords = df_1[['X', 'Y']].to_numpy()
distances = spsp.distance_matrix(coords, coords)
df_1['dist'] = distances.tolist()
df_1:
ID X ... mRNA dist
0 0 149.492 ... 0 [0.0, 34.759250639218344, 15.256919905406859, ...
1 1 115.084 ... 2 [34.759250639218344, 0.0, 20.26084919246971, 2...
2 2 135.331 ... 7 [15.256919905406859, 20.26084919246971, 0.0, 1...
3 3 136.965 ... 2 [13.36567727427235, 23.889894976746966, 10.466...
4 4 124.025 ... 1 [25.483468072458283, 9.800288261066603, 12.267...
5 2410 452.596 ... 0 [310.45531146366295, 343.201176433007, 323.167...
6 2411 196.448 ... 46 [152.2289183171187, 161.81988637061886, 151.96...
7 2412 190.779 ... 71 [135.69840306355857, 145.56501613025023, 135.4...
8 2413 202.941 ... 37 [155.75120368716253, 166.4410794996235, 156.02...
9 2414 254.967 ... 13 [208.86630390994137, 224.30899556192568, 211.6...