Pandas 如何在使用basemap函数检查结果时迭代数据帧

Pandas 如何在使用basemap函数检查结果时迭代数据帧,pandas,dataframe,latitude-longitude,matplotlib-basemap,Pandas,Dataframe,Latitude Longitude,Matplotlib Basemap,我正在尝试编写apython脚本,该脚本将对long/lat值进行几何变换,即旋转。但是,我希望生成long/lat以保留位置,例如,如果初始坐标在land中,我希望旋转的坐标也在land中。因此,我使用了basemap 我写了下面的脚本,它工作得很好,直到我尝试添加一个while循环。我添加while循环的目的是比较原始值和旋转值,如果它们不匹配,旋转角度将改变,直到它们匹配。我将在不首先添加while循环的情况下展示我的概念: def rotation(dfc): # Rota

我正在尝试编写apython脚本,该脚本将对long/lat值进行几何变换,即旋转。但是,我希望生成long/lat以保留位置,例如,如果初始坐标在land中,我希望旋转的坐标也在land中。因此,我使用了basemap 我写了下面的脚本,它工作得很好,直到我尝试添加一个while循环。我添加while循环的目的是比较原始值和旋转值,如果它们不匹配,旋转角度将改变,直到它们匹配。我将在不首先添加while循环的情况下展示我的概念:

   def rotation(dfc):
    # Rotation
     choose a rotation angle that will match the location of the rotated 
     coordinates, and set the result to 1 if they match
     while row['result']=0
        choose another rotation angle
        do the rotation again
        check the result of the rotated points
        if still they dont match stay in the loop and choose another alpha
        if not break and go to the next row

我知道它需要简单的步骤,但我无法想出如何在dataframes中为行函数添加循环

实际上,这个问题可以在不使用df.iterrows的情况下解决

我刚刚启动了一个等于0的变量,然后添加了一个while循环。所以我的伪代码看起来像:

  counter=0
  while counter != len(df['col1'])
       choose new random variable
       do the calculation using dfc.apply()
       re-calculate counter