title: Numpy automatically converting array of strings to array of numbers
body: <p>I have an array of strings that is composed of number-like strings such as <code>010</code>. I am trying to build a 2D numpy array by creating an empty numpy array, and then filling in the rows with my array of strings. However, it seems like whenever I assign a row in the numpy array, it converts the number-like strings into numbers. The main issue with this behavior is that I am losing leading zeroes from my strings.</p>
  <p>I wrote a simple example to show what is happening:</p>
  <pre><code>import numpy as np
  
  num_rows = 5
  arr = [&quot;010&quot;, &quot;011&quot;, &quot;111&quot;, &quot;100&quot;, &quot;001&quot;]
  np_arr = np.empty((num_rows, len(arr)), dtype=str)
  
  for i in range(len(np_arr)):
      np_arr[i] = arr
  
  print(np_arr)
  </code></pre>
  <p>The resulting output is:</p>
  <pre><code>[['0' '0' '1' '1' '0']
   ['0' '0' '1' '1' '0']
   ['0' '0' '1' '1' '0']
   ['0' '0' '1' '1' '0']
   ['0' '0' '1' '1' '0']]
  </code></pre>
  <p>vs. the expected output:</p>
  <pre><code>[['010' '011' '111' '100' '001']
   ['010' '011' '111' '100' '001']
   ['010' '011' '111' '100' '001']
   ['010' '011' '111' '100' '001']
   ['010' '011' '111' '100' '001']]
  </code></pre>
  <p>I do not understand this behavior and am hoping to find a solution to my problem and understand if this type conversion is being done by numpy or by Python. I have tried quite a few variations to this small example but have not found a working solution.</p>
  <p>Thanks!</p>