This is a list of integers (list_1).

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

This is a list of string (list_2).

['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

numpy is a tool, could turn list_1 to list_2

How can I improve this expression, "numpy could transfer each element to string type"


Numpy could convert each integer element into a string.

In programming changing variable type is usually referred to as "casting", "parsing" or "converting" and all could be used colloquially, but "converting" is the formally correct form, since "casting" deals with bits and is used to change the variable from one number type to another (for example float to int) which can cause the resulting number to be different, or loose the negative sign. Converting doesn't check bits, but deals with the real world values and tries to make the new variable look exactly the same. "Parsing" tries to take numbers out of a string, so "1a3" would be parsed into 13.

  • 1
    It needs to be into a string. Aug 1 '19 at 16:58
  • By my understanding, "casting" means "leave the underlying bits the same, but interpret them as a different type". Since the bits representing the int 1 and the string "1" are different, this isn't "casting". I'm not sure if you can do any casting in python. So I'd say "converting" is the better word to use.
    – James K
    Aug 5 '19 at 5:59
  • @JamesK you are correct.
    – TK-421
    Aug 5 '19 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy