OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

RuntimeWarning: invalid value encountered in double_scalars """

  • Thread starter Thread starter Waqar Ali
  • Start date Start date
W

Waqar Ali

Guest
This time i am incurring a problem while executing the following code:

Code:
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)

Generated Error is:

Code:
C:\...site-packages\ipykernel_launcher.py:5: RuntimeWarning: invalid value encountered in double_scalars
  """
C:\...site-packages\ipykernel_launcher.py:5: RuntimeWarning: divide by zero encountered in double_scalars
  """

I have checked

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

Code:
"""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()

Moreover, distance and speed are two variables/datsets present in excel and contain value either 0,1 or floating number.
<p>This time i am incurring a problem while executing the following code:</p>
<pre><code>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)
</code></pre>
<p>Generated Error is:</p>
<pre><code>C:\...site-packages\ipykernel_launcher.py:5: RuntimeWarning: invalid value encountered in double_scalars
"""
C:\...site-packages\ipykernel_launcher.py:5: RuntimeWarning: divide by zero encountered in double_scalars
"""
</code></pre>
<p>I have checked</p>
<blockquote>
<p>\ipykernel_launcher.py 'It's code is given below'.</p>
</blockquote>
<pre><code>"""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()
</code></pre>
<p>Moreover, distance and speed are two variables/datsets present in excel and contain value either 0,1 or floating number.</p>
 

Latest posts

Top