Python Forum
System showing np.int64(xxx) as output
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
System showing np.int64(xxx) as output
#1
I was using Numpy and try to find the number in an array which is the closest to the number 57. I write the following code.
a = np.array([78,22,65,87,12,98,63,79])
x = 57
a[np.argmin(np.abs(a - x))]
The output I get is
Output:
np.int64(63)
instead of 63 only. I am guessing it has to do with some setting in my system. Can you explain how I can get the number only without the data type? Thanks in advance.
Reply
#2
it seems correct ...

import numpy as np
a = np.array([78, 22, 65, 87, 12, 98, 63, 79])
x = 57

Index = np.argmin(np.abs(a - x))
minValue = a[Index]
print(f"Index = {Index} & min difference = {minValue}")

r = a[np.argmin(np.abs(a - x))]
print(f"r = {r}")
Output:
Index = 6 & min difference = 63 r = 63
leea2024 likes this post
Reply
#3
Are you running the code in an anaconda notebook? When I run your code as a program or in the interactive interpreter I don't see the np.int64() part. If you don't like the way the value is displayed, use the print() command.
leea2024 likes this post
Reply
#4
(Aug-10-2024, 10:20 AM)deanhystad Wrote: Are you running the code in an anaconda notebook? When I run your code as a program or in the interactive interpreter I don't see the np.int64() part. If you don't like the way the value is displayed, use the print() command.

Yes, I am running my code in JupyterLab. Would you mind telling me why the output is different in JupyterLab?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Showing and saving the output of a python file run through bash Rim 3 3,575 Oct-06-2021, 10:48 AM
Last Post: gerpark
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 17,756 Jan-11-2021, 06:30 PM
Last Post: ykumar34
Question Difference between Python's os.system and Perl's system command Agile741 13 7,958 Dec-02-2019, 04:41 PM
Last Post: Agile741
  Not Getting The desired output on my system Rashi 12 8,916 Apr-24-2017, 06:33 AM
Last Post: Rashi
  os.system Output S0undwav3 8 25,369 Mar-02-2017, 06:13 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020