(Python)RuntimeWarning:在双标量“”中遇到无效值

2024-03-28 21:25:14 发布

您现在位置:Python中文网/ 问答频道 /正文

晚上好

我是Python的初学者,每天都在学习一些新东西。 这次我在执行以下代码时遇到问题:

distance = [np.nan]
speed = [np.nan]
for i in range(1,len(data)):
    distance_dt = distance_cal(data.loc[i-1,'latitude'],data.loc[i-1,'longitude'],data.loc[i,'latitude'],data.loc[i,'longitude'])
speed_dt = distance_dt/(data.loc[i,'delta_time']/3600)
distance.append(distance_dt)
speed.append(speed_dt)
data['distance'] = np.around(distance, decimals=6)
data['speed'] = np.around(speed, decimals=6)

生成的错误是:

C:…站点包\ipykernel_launcher.py:5:运行时警告:在双标量中遇到无效值 """ C: …站点包\ipykernel_launcher.py:5:运行时警告:除以在双标量中遇到的零 “”

我查过了

\ipykernel_launcher.py 'It's code is given below'.

"""Entry point for launching an IPython kernel.

This is separate from the ipykernel package so we can avoid doing import until
after removing the cwd from sys.path.
"""

import sys

if __name__ == '__main__':
    # Remove the CWD from sys.path while we load stuff.
    # This is added back by InteractiveShellApp.init_path()
    if sys.path[0] == '':
        del sys.path[0]

    from ipykernel import kernelapp as app
    app.launch_new_instance()

此外,距离和速度是excel中的两个变量/数据集,包含0、1或浮点数。

任何帮助都将不胜感激。

谢谢你。


Tags: thepathfrompyimportdataisnp