我正在尝试使用以下代码遍历4x3的数据框:
R = []
Ratio = pd.DataFrame(R)
for column in Three_Distances:
column_location = Three_Distances.columns.get_loc(column)
for rows, row in Three_Distances.iterrows():
if column == 'post_one':
Ratio[column_location,rows] =
1/Three_Distances[column].divide(D1_theoretical)
if column == 'post_two':
Ratio[column_location,rows] =
1/Three_Distances[column].divide(D2_theoretical)
if column == 'post_three':
Ratio[column_location,rows] =
1/Three_Distances[column].divide(D3_theoretical)
我的变量Ratio输出是4x12而不是4x3。我想知道我是否不正确地理解我正在使用的工具或循环?
谢谢