0

If I wish to get the name of a numpy.ndarray converted to a string (but not the content of the numpy.ndarray, just the name only), how do I do that?

I tried str(npndarrayName) and npndarrayName.tostring() but both are converting the content and not the name itself only.

Geeky Quentin
  • 2,469
  • 2
  • 7
  • 28
NoTisan
  • 27
  • 5
  • 3
    Does this answer your question? [Getting the name of a variable as a string](https://stackoverflow.com/questions/18425225/getting-the-name-of-a-variable-as-a-string) – Adam Jaamour Jun 08 '22 at 15:20
  • In Python objects don't have names. An object may be assigned to a variable - or many variables, or none. So while is may, in some cases, be possible to look for the object in the global namespace, I question the practicality of this. Why do you want/need to do this? – hpaulj Jun 08 '22 at 15:33
  • @hpaulj for a project. I want to plot something from a np.ndarray with its name as the legend. – NoTisan Jun 08 '22 at 15:41

1 Answers1

1

I am not sure if I fully understood what you're asking, but you can check this link because I think they had the same question as you. I hope that it will solve your problem.

Paschalis Ag
  • 128
  • 6