教授给了我这个R代码的任务...
# Simulate the error vector
#
e <- dist(9,...)
...进入Python。我知道这是距离矩阵计算,所以我在Python上搜索了Google并得到了scipy.spatial.distance_matrix
我在这段代码中用它来尝试匹配R ...
e = sps.distance_matrix([[0,0],[0,9]], [[9,0],[9,9]])
但是我认为输出不正确。
使用熊猫
import pandas as pd
col1 = [x+10 for x in range(3)]
col2 = [x+100 for x in range(3)]
df = pd.DataFrame(list(zip(col1,col2)))
print(df)
#RESULT
# 0 1
#0 10 100
#1 11 101
#2 12 102